Using custom fields in an interactive experiment
There might scenarios when you need to use logic in an interactive experiment that relies on an attribute that Sitecore Personalize does not capture. For example, you might want to only run an experiment for visitors who are logged in to your organization's website. Since this is not automatically captured by Sitecore Personalize, you can create a custom field called “loggedInState”
, and use this data when you build the experiment.
You can use custom fields when using the following features:
-
Compose the API request: Include the custom field in the API request, using FreeMarker. For example, retrieve the value of the custom field and use it in further logic.
-
Creating custom conditions: Use the value of the custom field to determine whether to execute the experiment.
-
Creating programmable decisions: Use the custom field as logic in a programmable decision to determine the next best action or offer.
You can send any custom field in the POST
request using the Sitecore Personalize REST API. You must use the params
key as shown in the following example:
{
"clientKey":"abBah8aelipaPeebae7roox2tiexoSee",
"channel":"WEB",
"language":"en",
"currencyCode":"EUR",
"pointOfSale":"retailsite.com",
"browserId":"56860bff-94ba-4d84-aa37-2b5a83d5411b",
"friendlyId":"home_page_banner",
"params":{
"loggedInState":"logged in"
}
}
Avoid using custom fields throughout your business logic
As a general rule, separate your business logic so that you do not use the same custom field in logic within a custom condition, decisioning, and API request unless necessary.