Skip to main content
Users
CloudPortalLogin
  • 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
AI in Personalize
Glossary
  • Sitecore Personalize
  • Introduction to experiments in Sitecore Personalize
  • Introduction to web experiments in Sitecore Personalize
  • Create a web experiment
  • Create a variant for a web experiment using custom code

Create a variant for a web experiment using custom code

To apply personalization to a web experiment , you can create a variant using custom HTML, CSS, or JavaScript. When Sitecore Personalize runs the web experiment, it will execute any HTML, CSS, or JavaScript configured in the variant.

For personalization to work, the variant needs to pass guest data to your organization's website. This includes details like the guest's first name, location, loyalty number, and so on. This information is known as server-side data. To facilitate, you need to compose the API request using FreeMarker, then reference it in the relevant HTML, CSS, or JavaScript code.

To create a web experiment variant using custom code:

  1. In the Experiment variants tile, click Create variant.

    Note

    You can create a maximum of six variants in each experiment.

  2. In the Select template pane, click Create template.

  3. In the code editor, use custom code on the relevant HTML, CSS, or JavaScript tabs.

  4. Compose the API request using FreeMarker.

  5. Click Save.

  6. Click to close the code editor.

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2025 Sitecore