Conditions
To deliver a personalized experience or experiment to your website's visitors, you must create a variant and define its audience using conditions. Conditions determine when the variant is shown based on visitor's real-time behavior. Only visitors who meet these conditions will see the variant.
The audience for an experience or experiment can be filtered using out-of-the box conditions and custom conditions. To refine the filtering further, you can apply multiple conditions or group them to manage how they are evaluated.
You cannot use JS modules in conditions. JS modules are only supported in programmables within decision models.
Types of conditions
-
Out-of-the box conditions - Sitecore Personalize provides prebuilt conditions that are ready to use. These conditions require no additional coding, making them quick and easy to apply.
-
Custom conditions - Developers can create custom conditions using JavaScript, transforming complex code into a user-friendly interface for marketers. Custom conditions can be built by modifying an existing out-of-the box or custom condition, or creating a new condition from scratch.
Using conditions
Marketers can apply up to five conditions to experiments and experiences to tailor them based on visitor behavior. All a marketer has to do is simply select an out-of-the-box or a custom condition, provide the necessary details, and apply it to the experience or experiment without writing or editing code.
For example, you can apply an out-of-the-box condition to target visitors based on their real-time geolocation or device type, as shown here:
Adding multiple conditions
You can add multiple conditions to an experiment or experience when filtering audiences. You can combine out-of-the-box and custom conditions to further refine your audience. Whether you combine conditions or group them to evaluate them together, the total number of conditions cannot exceed five.
Multiple conditions are designed to always evaluate to true or false. A single condition might still return a value. Before applying multiple conditions, make sure you understand the order of operations in conditions and follow the best practices for creating custom conditions to ensure robust and predictable logic.
-
Combine conditions - you can add up to five conditions to an experiment or experience and connect them using the And or Or operators to define how they are evaluated.
Example: Two conditions combined using the Or operator.
In this example, the variant is shown to visitors if they are either in California or in New York during their current visit.
-
Group conditions - you can create a group of conditions to evaluate them together, as part of the set of conditions that create the audience. Groups can contain up to five conditions, but the total number of conditions, whether grouped or individual, must not exceed five.
Example: Combination of a condition and a group of conditions for more complex logic.
In this example, the variant is shown to visitors who are new to the site and are located in either California or New York during their current visit.
Understanding the order of operations in conditions
When adding multiple conditions, the order and hierarchy of the conditions that build an audience determines the how the audience is calculated:
-
When the outcome of a condition (or group of conditions) is evaluated to true for a visitor, the evaluation stops and the visitor is assigned to the relevant audience.
-
The experience or experiment variant is displayed according to the audience the visitor is assigned to.
-
At every page visit, the audience is reevaluated. For example, if after browsing your site, a page views condition changes and evaluates to true, the visitor might now be assigned to a different audience.
Conditions are evaluated in the order in which they appear, using the following logic:
-
Group - conditions within a group are evaluated first, based on their order within the group.
-
And - conditions that are preceded by the And operator are evaluated next.
-
Or - conditions that are preceded by the Or operator are evaluated last.