Run an interactive experience
After you create an interactive experience, you can test it by sending a payload of data to Sitecore Personalize that simulates a customer interaction and triggers the experience.
We recommend doing this for sophisticated experiencess that use custom fields. For more simple experience, you can preview the api response instead of testing the code.
There are different options to run an interactive experience:
-
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 experience. You must call this function with the friendlyId of the live experience you want to run.
Here's an example of how to run an experience 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" }
}