Skip to main content
Sitecore Documentation
Personalize logo
Users
Developers
Changelog
  • Powered byPowered by
Introduction to Sitecore Personalize
Managing accounts and system settings
Identifying guests
Introduction to experiments
Introduction to experiences
Decisioning
View dashboards
Developer Center
Connecting to an external system
Using client-side JavaScript
Using server-side JavaScript
  • Sitecore Personalize
  • Introduction to experiences
  • Introduction to web experiences in Sitecore Personalize
  • Using custom code in a web experience variant
  • Use HTML in a web experience
Edit in Paligo

Use HTML in a web experience

Abstract

Describes how to use HTML in a web experience to use dynamic data (Sitecore Personalize).

You can HTML in a variant for an experience, which is particularly useful for facilitating 1:1 personalization by running dynamic data.

Most variants must also pass guest data to your organization's website, for example, the guest's first name, location, and loyalty number. To do 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. For example, you might want to display offers in an experiment that are returned from a decision model. Because the offer is a value that is nested in an array, you must use the array.index or array.{index} handlebars.js syntax.

If the web experience is configured with a decision model, you can insert attributes returned by the decision model into the HTML.

To use HTML in a web experience:

  1. On the Build screen, in the Experience section, click the Edit icon next to the variant you want to configure.

  2. In the template editor, on the HTML tab, enter any HTML that you want to use in the web experience.

  3. To insert dynamic data into HTML, on the Data tab, in the Data Selector search box, enter a guest's email address to search. This enables you to access data model attributes and paths.

    Tip

    If there is a guest whose data you often use when configuring or testing code, click the star icon to bookmark the guest so you no longer have to search for them.

    Editing the HTML to apply personalization in a variant.
  4. To include dynamic data from the decision model response, expand the Decision Model Response tree, click and Copy Path as Handlebars.

  5. To include dynamic data from the experience response, expand the Experience Response tree, click and Copy Path as Handlebars.

  6. On the HTML tab, paste the data and click Save.

  7. Click to return to the Build screen.

    You must also include the dynamic data when you compose the API response. This ensures that when the experience executes, the server requests the dynamic data and passes it to the variant.

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2023 Sitecore