|
||
When setting up a personalized page, the most important part of the process is to properly define the conditions that indicate when individual variants should be displayed. By utilizing macro expressions, you can write conditions for virtually any type of scenario according to your specific requirements. Keep in mind that the result of a condition's expression must be a logical (boolean) value in order for it to work correctly. For details about available macro options and syntax, please refer to the Development -> Macro expressions chapter.
A variant's condition is specified in its Display condition property.
Through the edit icon (), you can use the macro condition editor, which provides a graphical interface that makes it easier to build complex conditions. It allows non-technical users to create conditions based on predefined macro rules. Please see the Macro conditions topic for further details.
On the live site, each personalized object will only have one of its variants displayed at any given moment. Variants are processed in the order of their priority and the first enabled variant whose condition is fulfilled in the current context will be selected. The original object is displayed in cases where the conditions of all variants are resolved as false.
By default, the priority of variants depends on the order in which they were created, as can be seen 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.
If you wish to change the order in which an object's variants should be processed, click the Variant list () button among the actions on the slider. A dialog containing a list of the variants will be opened as shown below.
Here, you can reorganize the variants as necessary through the Up () or Down () actions.
The example below demonstrates how you can build a macro that causes the given variant to be displayed only during a specific part of the day, or to users with special authorization.
1. Create a content personalization variant for an object, open its properties dialog and click the edit icon () next to the Display condition field to open the macro condition editor.
2. Switch to the Designer tab and remove () any existing expressions. Then click the Add Group () action and use Add expression () to create two expression fields inside the new group. Fill in the expressions according to the following instructions:
•Enter CurrentDateTime.Hour into the field on the left, select the is greater than or equal to operator and write 9 on the right.
•Enter CurrentDateTime.Hour into the field on the left, select the is less than or equal to operator and write 17 on the right.
Leave the AND option selected between the two expressions.
3. Add another expression to the main area and select the OR option between it and the group. Enter CurrentUser.IsInRole("GoldPartners") into the expression's field and select is true as the operator.
4. Click OK and the code of the condition will be inserted into the Display condition field:
(CurrentDateTime.Hour >= 9 && CurrentDateTime.Hour <= 17) || CurrentUser.IsInRole("GoldPartners")
This condition ensures that the variant is only displayed to ordinary users if the current time is between 9 AM and 5 PM. Users who belong to the GoldPartners role will be able to see the content specified by the variant at any time.
Alternatively, you can also define the same condition through macro rules. Click the Clear condition () action next to the field and edit () the condition again.
1. On the Rule designer tab, select the Current day time is in range macro rule and use the Add rule () button to insert it into the condition.
2. Do the same for the Current user is in one of specified roles rule and leave the and operator between the two clauses in the designer area.
3. Click on the underlined parameters in the text of the rules to set the time and role values that were used for the original condition.
This time, clicking OK inserts the variant's display condition as a user-friendly expression composed of macro rule clauses.