Run an interactive experiment
After you create an interactive experiment, you can test it by sending a payload of data to Sitecore Personalize that simulates a customer interaction and triggers the experiment.
We recommend doing this for sophisticated experiments that use custom fields. For more simple experiment, you can preview the api response instead of testing the code.
There are different options to run an interactive experiment:
-
Using functions provided by the Engage SDK or Cloud SDK.
-
Sending a POST request using the Personalize REST API.
-
Using the Chrome DevTools console with
Boxever.js(legacy).
Engage SDK
If you are using the Engage SDK, you can use the Engage.personalize(personalizationData[, timeout]) function to run an interactive experiment. You must call this function with the friendlyId of the live experiment you want to run.
Here's an example of how to run an experiment and log it to the console.
import { engage } from "./engage.js";
// ...
const handlePersonalization = async () => {
const response = await engage.personalize(personalizationData);
console.log(response);
};
Here's an example of a personalization data object. This object doesn't contain the email attribute or the identifier attribute to identify the guest. This personalization data object also contains an optional custom field.
const personalizationData = {
channel: "WEB",
currency: "EUR",
pointOfSale: "myretailsite/ireland",
friendlyId: "running_shoes_popup_02",
// optional attributes:
params: { key: "value" }
}