Skip to main content

Build a real-time audience in a triggered experiment


How to build a real-time audience in a triggered experiment (Sitecore Personalize).

If you are familiar with JavaScript, you can follow these instructions to build a real-time audience. Alternatively, you can apply a real-time audience template without needing to write, edit, or view code.

You can use custom fields when building your real-time audience. You can then reference the custom field when building your real-time audience, by using the following syntax:


To avoid errors when including dates and times in JavaScript for real-time audiences, use the moment.js library. The moment.js library enables you to parse, validate, manipulate, and display dates and time formats in JavaScript.



If you chose or created a custom event trigger, you can select the event name when composing your JavaScript.

To build a real-time audience:

  1. From the Build screen, in the Audience block, click Add. The Audience slider modal displays.

  2. Click the Real-time Audience block. The window refreshes with a list of audience templates.

  3. Click the Add Custom Code link. The Custom Real-Time Audience screen displays.

  4. Enter the JavaScript that you want Sitecore Personalize to use to determine whether to run the experiment. As you write your JavaScript, ensure that you consider the data limits in real-time audiences.

    The experiment only runs for guests who match the guest attributes you define in the JavaScript and who are members of the selected segment, if applicable.

    You can use any real-time data made available by an internal service known as the Guest Context Service. As you type your JavaScript, predictive helpers display the attributes you can leverage from this service.

  5. Click Save. You return to the Audience slider modal.

  6. Click Save. You return to the Build screen.