Create an audience template

Abstract

Describes how to create an audience template that you can make available to other users when they build an experiment (Sitecore Personalize).

An audience template is effectively a real-time audience that you configure and make available to other users when they build an experiment.

When you create an audience template, you can leverage any real-time data made available by an internal service known as the guest context service.

You can optionally create a form for an audience template. When the marketer selects the audience template, the form displays for the marketer to complete. This enables the marketer to configure real-time audience logic without having to write or edit code.

To create an audience template:

  1. In the navigation pane, click Library, Audience Templates. The Audience Templates screen displays.

  2. Click Create Template. The Title of template dialog box displays.

  3. In the Name your Template field, enter an intuitive name for the audience template.

    As you type, the name of the template displays in the ID field.

  4. Click Create. The JavaScript template editor displays for you to customize using JavaScript. As you write your JavaScript, ensure that you consider the data limits in real-time audiences. You can optionally create a form to display that enables the marketer to further configure the audience.

  5. On the Settings tab, in the Description field, enter a description of the audience template .

  6. Click Save.

  7. In the audience template, in the top-right corner, click the toggle switch to put the template in the published state to make it available to the marketer when building a real-time audience.

Create a guest type audience template

You can create a form that uses the guestType attribute as a condition to run the experiment. When the marketer selects the audience template, they must enter customer, visitor, or traveller in the guest type field on the form.

To create a guest type audience template:

  1. Follow the Create a form for an audience template topic.

  2. Copy and paste the following JavaScript into the JavaScript editor.

    // Adds a field on a form that enables the marketer to enter the required guest_type to run the experience.
    
    (function () {
      'use strict'
      if (guest.guestType && guest.guestType === "[[ guest type | text]]") {
          return true;
      }
    })();
  3. Click Save.

Create a guest email address audience template

When you test a triggered experiment, you must ensure that you do not send any unintentional email messages. You can create a form that uses a string within the guest's email address as a condition to run the experiment. When the marketer selects the audience template, they must enter the string in the guest's email address that they want to use as a condition on the form.

For example, if the marketer only wants the email message to be distributed to members of their email domain, they can include mydomainname.com. Similarly, if they only want the email message to be distributed to themselves when testing, they can enter their own unique email address, such as johndoe@mydomainname.com.

To create a guest email address audience template:

  1. Create a form for an audience template.

  2. Copy and paste the following JavaScript into the JavaScript editor.

    // Adds a field on a form that enables the marketer to enter a string that must be present in an email address to run the experience. (function() { if (guest.email && guest.email.indexOf("[[Email includes | string]]") > -1 ) { return true; } return false;
    })();
  3. Click Save.