---
title: "Variations and rules"
slug: "variations-and-rules"
abstract: "Widget variations and rules in Sitecore Search and how to use them to create experiences."
---
# Variations and rules

In Sitecore Search, a widget's configuration is stored in variations. You can create as many variations as you need, but only one is set as *Active* at any time. Similarly each page also has an active variation.

At runtime, the headless response from Search includes the active page variation and active variations of all widgets in it.

> [!tip]
> With variations, you can:
>
> -   Have page variations with different widgets.
>
> -   Schedule switching pages or widget variations.
>
> -   Split test variations to identify which one best meets your business needs.

Widget variations contain rules that modify behavior in predefined contexts. For example, *Use Recipe A when visitor is from Canada otherwise use Recipe B*. A variation can have multiple rules as long as no two rules are duplicates or contradict one other.

At runtime, when Sitecore Search receives a data request for a widget, it uses the active variations of both the global widget and the requested widget to create a consolidated configuration, which it then uses to generate results.

In the variation framework, all widgets inherit the configuration of the active global widget variation. If you add rules to a variation of a widget, they're assigned the highest order of precedence, meaning they take priority over any conflicting rules inherited from the global widget.

## Rule settings

All rules have *Context*, *Strategies*, and *Settings* sections that contain all the configuration required to optimize results. Rules for recommendation widgets also include a section named *Recipe*, which is used to set the recipe or AI algorithm in the search process.

In Search, variations and the rules they contain play an important role in optimizing results. A rule[^UUID-48c6b92f-d97a-3d5b-9006-85685f9183f0_N6762849012bd2] only alters the behavior of a widget variation[^UUID-48c6b92f-d97a-3d5b-9006-85685f9183f0_N677e71d1b3127] when the conditions described in the *Context* are met.

The following image shows the three sections to the left (*Context*, *Strategies*, and *Settings* ) as available for preview search and search results widgets.

![Placeholder items in the Strategies section of a new rule.](https://doc.sitecore.com/api/markdown-image/search/en/users/search-user-guide/images/rule-strategies.png)

### Context

In the **Context** section of a rule, you define the criteria for when a rule applies. There are two types of context:

- **Site** context defines where in the site a visitor must be for the rule to take effect.
- **Visitor** context defines what aspects about a visitor affect whether the rule applies to them, such as if they are new or returning visitors.

The immediate advantage of setting context values is control over who can see certain results and when they are displayed. If you do not set a context, the rule applies to all site areas and to all visitors.

> [!tip]
> When you set a context for a rule, the rule editor displays a sample set of items that a visitor will see if they fit that context.

> [!important]
> To set a rule context that always applies to all widgets, you can add it to a global widget variation and then set the variation's status to *Default*.

### Recipes

In the **Recipes** section of a rule, you can assign the recipe or AI algorithm used to generate results for the recommendation widget.

### Strategies

In the **Strategies** section of a rule, you can configure how results are prioritized, excluded, or included, such as:

- *Pin* an item to a specific slot in the widget's display.
- *Boost* and include specific items.
- *Bury* and *block* items.

### Settings

In the **Settings** section of a rule, you can modify the priority and availability of feature options created for domain-wide use, which include:

- [Facets](https://doc.sitecore.com/search/en/users/search-user-guide/refine-search-results.html "Refine search results") 
- [Sorting](https://doc.sitecore.com/search/en/users/search-user-guide/refine-search-results.html "Refine search results") 
- [Textual relevance](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results.html "Display relevant results") 
- [Search ranking](https://doc.sitecore.com/search/en/users/search-user-guide/personalize-results.html "Personalize results") 
- [Personalization](https://doc.sitecore.com/search/en/users/search-user-guide/personalize-results.html "Personalize results") 

The following lists some typical examples:

- Overriding default user interactivity, facets, and sorting options in search results widgets.
- Displaying trending items and search ranking options in preview search widgets.

> [!important]
> You cannot create new options within a rule or the global widget.
>
> To create new options or edit existing ones, go to the **Feature configuration** tab on the **Administration** > **Domain settings** page.

## Use cases

You can create as many rules as you need to cover various context scenarios and your business needs.

The following are some typical use cases for rules:

- [Rank results based on a referring URL](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/configure-results-using-context.html#UUID-37854a10-7333-f848-829b-6bd3110853b7_section-idm4661230943534433670860786083 "Rank results based on a referring URL") 
- [Pin an item in all widgets](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/prioritize-results.html#UUID-e9d97c52-633d-88e9-5936-709712a42bb9_section-idm1743366612934988 "Pin an item in all widgets") 
- [Bury an item in the results](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/exclude-or-bury-results.html#UUID-231497cd-0ee0-ead4-eeaf-1dce99b1894c_section-idm1743367150863062 "Bury an item in the results") 

A typical use case for variations is to [schedule a variation with rules that reflect a campaign](https://doc.sitecore.com/search/en/users/search-user-guide/display-relevant-results/add-or-edit-widget-variations.html "Add or edit widget variations").

[^UUID-48c6b92f-d97a-3d5b-9006-85685f9183f0_N6762849012bd2]: A modification to widget behavior that can be used to overwrite the natural set of results, for example, to boost, bury, pin, and blacklist items. A rule can have its own variations as well as its own rules, and is evaluated when called from the customer website.

[^UUID-48c6b92f-d97a-3d5b-9006-85685f9183f0_N677e71d1b3127]: A customized widget that contains rules that impact search results, which can be used to schedule content to appear at specific times or under certain conditions.  
    
    For example, you can use a widget variation to emphasize specific items on your website for a certain time period, such as summer or Black Friday, or use it to display content for specific devices.
