Skip to main content

Using JavaScript in a web experience


Introduction to using JavaScript in a web experience (Sitecore Personalize).

To make a web experience to go-live on your organization's site, you must specify in the JavaScript editor where in the Document Object Model (DOM) you want the offer or content to display. This is how you determine where the HTML will be inserted and rendered on your organization's website.

The JavaScript editor lets you run client-side JavaScript in your variant.

Most variants also must pass server-side guest data to your organization's website, for example, the guest's first name, location, loyalty number, and so on. To facilitate this, you must configure the API response to include the dynamic data so that when the variant executes, the data is requested from the server and then passed to the variant.

You can use Handlebars.js to access nested values by index from the API response.


The experience can call server-side data such as guest attributes, and use it in the CSJS. This can include a full history of the guest as well as a continuous stream of real-time session data.