---
title: Setting display conditions for personalization variants
related:
  - https://docs.kentico.com/k81/on-line-marketing-features/content-personalization/managing-personalization-variants.md
  - https://docs.kentico.com/k81/macro-expressions/writing-macro-conditions/building-conditions-using-macro-rules.md
  - https://docs.kentico.com/k81/macro-expressions/writing-macro-conditions.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Info:** **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. 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. For more information about the available macro options, refer to the [On-line marketing macros](https://docs.kentico.com/k81/on-line-marketing-features/on-line-marketing-macros.md) page.

Specify the condition of each variant in its **Display condition** property.

![Configuring personalization variant properties](https://docs.kentico.com/docsassets/k81/setting-display-conditions-for-personalization-variants/configuring_webpart_variant_properties.png "Configuring personalization variant properties")

- 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.

## 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. The page displays the original object 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. 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.

![Managing personalization variants](https://docs.kentico.com/docsassets/k81/setting-display-conditions-for-personalization-variants/managing_variants.png "Managing personalization variants")

To change the priority of a component's variants:

1. Click the **Variant list** button on the object's personalization slider.

   - A dialog containing a list of the variants opens.

   ![Reorganizing personalization variants](https://docs.kentico.com/docsassets/k81/setting-display-conditions-for-personalization-variants/managing_variant_order.png "Reorganizing personalization variants")
2. 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](https://docs.kentico.com/k81/macro-expressions/writing-macro-conditions/building-conditions-using-macro-rules.md). The condition causes the page to display the given variant only during a specific part of the day, or to users with special authorization.

1. [Create a content personalization variant](https://docs.kentico.com/k81/on-line-marketing-features/content-personalization/managing-personalization-variants.md) for a page component.
2. Click **Edit condition** next to the **Display condition** field in the variant properties dialog.
3. On the **Rule designer** tab, select **Current day time is in range** in the list of macro rules.
4. Click **Add rule** (). The selected rule appears in the condition.
5. Add the **Current user is in role** rule.
6. Click the **and** operator between the two clauses in the designer area. The operator changes to **or**.
7. Click on the underlined parameters in the text of the rules and set the required time and role values.

   ![Designing a macro using the Rule designer](https://docs.kentico.com/docsassets/k81/setting-display-conditions-for-personalization-variants/editing_macro_condition.png "Designing a macro using the Rule designer")
8. Click **Save & Close**.

The condition builder inserts the variant's display condition as a user-friendly expression composed of macro rule clauses.

Alternatively, you can enter the condition directly using [K# macro syntax](https://docs.kentico.com/k81/macro-expressions/macro-syntax.md). For example:

```text

(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.
