Setting display conditions for personalization variants
Kentico EMS required
Features described on this page require the Kentico EMS license.
When setting up personalized pages, the most important part of the process is to properly define the conditions that indicate when the system displays individual variants. You can build personalized conditions using the macro condition editor.
To edit the display conditions of the existing personalization variants:
Open the Pages application and select the personalized page in the page tree.
Switch to the page’s Properties -> Variants tab.
Edit () the selected personalization variant.
Specify the variant’s Display condition property.
- Click Edit to use the Macro condition editor, which allows non-technical users to create conditions based on predefined macro rules.
- The Clear action removes the current content of the condition field.
Click Save.
See also: Example - Building a personalization condition
Setting the priority of personalization variants
On the live site, the page displays only one variant for each personalized object. The system processes variants in the order of their priority and selects the first enabled variant whose condition is fulfilled in the given context.
By default, the priority of variants depends on the order in which they were created. You can see the current order on the personalization slider. Apart from the original object, which is always first, variants with a higher priority can be found further on the left of the slider.
To change the priority of a page component’s variants:
- Click the Variant list button on the object’s personalization slider.
A dialog containing a list of the variants opens.
- Reorganize the variants as necessary through the Up () or Down () actions.
The system now evaluates the conditions of the component’s variants according to the new order, starting from the top of the list.
Example - Building a personalization condition
The following example demonstrates how to build a condition using macro rules. The condition causes the page to display the given variant only during a specific part of the day, or to users with special authorization.
Create a content personalization variant for an editor widget or a web part and web part zone.
Click Edit next to the Display condition field in the variant properties dialog.
On the Rule designer tab, select Current day time is in range in the list of available rules.
Click Add rule ().
- The selected rule appears in the condition.
Add the Current user is in role rule.
Click the and operator between the two clauses in the designer area. The operator changes to or.
Click on the underlined parameters in the text of the rules and set the required time and role values.
Click Save & Close.
The condition builder inserts the variant’s display condition as a user-friendly expression composed of macro rule clauses.
Alternatively, your developers can help you enter the condition directly on the macro condition editor’s Code tab or in the variant’s Display condition field using K# macro syntax. For example:
(CurrentDateTime.Hour >= 9 && CurrentDateTime.Hour <= 17) || CurrentUser.IsInRole("GoldPartners")
This sample condition ensures that the variant is only displayed to regular users if the current time is between 9 a.m and 5 p.m.. Users who belong to the GoldPartners role can see the variant’s content at any time.