Interactive personalization
You can use the Cloud SDK personalize package to run interactive personalizations (interactive experiences and interactive experiments) that are live in Sitecore Personalize. These personalizations are typically created by developers in Sitecore Personalize and delivered to site visitors via APIs. This type of personalization is used to show offers or operational messages with personalized, dynamic content usually retrieved from back-end systems to site visitors.
Cloud SDK developers can run a live interactive experience or experiment in their web app by using the personalize function available in all modules of the personalize package.
In the personalize package, the browser module lets you run personalization from the browser, and the server module lets you do it from the server. When you run the personalize function, you have to pass it the personalize data object. In this object, you have to provide the friendly IDfriendly ID of the experience or experiment you want to run, and specify the channel. Optionally, you can specify more event and experiment data.
When you run an interactive personalization, two things happen:
-
As part of the network request, a payload is sent to Sitecore. The payload contains the friendly ID of the experience or experiment you want to run, and other required and optional data that you included in the personalize data object. If the URL of the webpage where the
personalizefunction runs contains UTM parameters, the payload will also contain the UTM parameters. -
The personalized content is returned as part of the API response. You can use the API response to display content to your site visitor or take other actions, depending on your application requirements.
Example of interactive experience
In this example, you can display a personalized message to your site visitor depending on when they were first seen on your site.
Consider an interactive experience that is live in Sitecore Personalize. This experience has the friendly ID interactive_1, and its API response returns the date the site visitor was first seen on your site:
You can run this experience on your site by running the asynchronous personalize function, passing in the friendly ID of the experience. The function returns the API response of the experience. You can save the return value into a variable, for example, personalizeResponse, then log the value to the console:
The following is logged to the console:
If the API response is {"message":"No flow executed"}, make sure to start the experience or experiment so it's live in Sitecore Personalize.