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.
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.
Cloud SDK
If you are using the Cloud SDK, you can use the personalize function to run an interactive experiment that is live in Sitecore Personalize.
Here's an example of how to use the personalize function for Next.js:
REST API
You can run an interactive experiment by making a POST request using the Personalize REST API.
You must use the browserId, email, or identifiers to send a flow execution request.
Here's an example of running an experiment using the browserId:
Boxever.js (legacy)
You can use the Chrome DevTools console to run JavaScript for an interactive experiment using Boxever.js. This method runs the request from your website where the Boxever.js library is installed and is commonly used as it requires minimal setup.
Here's an example of JavaScript you can use to run an interactive experiment via Chrome DevTools:
To include custom parameters in the payload request, add the key parameters into the flowData object, and add your custom params as key/value pairs as shown in the following JSON example.