> ## Documentation Index
> Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contextual conditions

> Control when merchandising rules apply based on visitor session data like geographic location, customer attributes, and marketing channels.

Contextual conditions let you control when a merchandising rule applies based on visitor session data. Target specific audiences with tailored merchandising strategies by combining conditions in the dashboard.

## How contextual conditions work

Contextual conditions are evaluated at request time against session context data including:

* **Geographic data**: Country, state/province, city
* **Market data**: Market ID, market handle, market countries
* **Customer attributes**: Customer tags, account status, purchase history
* **UTM parameters**: Marketing source, medium, campaign
* **Device information**: Device type, operating system
* **Shopping channel**: Online store, mobile app, etc.

Each condition checks a visitor attribute against one or more values using an operator (equals, does not equal, is in list, etc.). If the condition evaluates to true for the current visitor, the rule is applied. Rules without contextual conditions always match and act as default/catch-all rules.

When [multiple rules](/platform/merchandising/multiple-rules) target the same collection, rules with contextual conditions are always evaluated before default rules. This ensures that a more specific conditional rule is never blocked by a default rule, regardless of creation order.

## Condition examples

The contextual conditions form in the dashboard lets you build these targeting rules without writing code. Below are common examples of what you can set up.

**Target US visitors:**

| Field   | Operator | Value |
| ------- | -------- | ----- |
| Country | equals   | US    |

**Target mobile users in California (combine with AND):**

| Field  | Operator | Value  |
| ------ | -------- | ------ |
| State  | equals   | CA     |
| Device | equals   | mobile |

**Target visitors from specific marketing campaigns:**

| Field              | Operator   | Value                      |
| ------------------ | ---------- | -------------------------- |
| Marketing campaign | is in list | summer-sale, holiday-promo |

**Target visitors from a specific Klaviyo campaign:**

| Field             | Operator | Value             |
| ----------------- | -------- | ----------------- |
| Klaviyo: Campaign | equals   | Summer Sale (SMS) |

The **Klaviyo: Campaign** field is available once you connect Klaviyo under **Settings → Integrations**. Select a campaign from the dropdown and Layers matches shoppers whose session UTMs came from that campaign across email, SMS, and push. See [Klaviyo](/shopify-integration/third-party-integrations#klaviyo) for setup details.

**Target customers with specific tags:**

| Field         | Operator | Value |
| ------------- | -------- | ----- |
| Customer tags | contains | vip   |

You can target shoppers based on Shopify customer tags (for example, "vip", "wholesale", or any tag synced from Shopify). Use "is in list" or "is not in list" to match against multiple tags, or "contains" to match any tag that includes a substring.

**Target visitors in a specific Shopify Market (by handle):**

| Field         | Operator | Value |
| ------------- | -------- | ----- |
| Market handle | equals   | ca    |

**Target visitors in markets that include a specific country:**

| Field            | Operator | Value |
| ---------------- | -------- | ----- |
| Market countries | contains | US    |

## Case sensitivity

String-based condition operators are **case-insensitive**. A condition matching "klaviyo" also matches "Klaviyo" or "KLAVIYO". This covers `equals`, `does not equal`, `in`, `not in`, `contains`, `does not contain`, `begins with`, `does not begin with`, `ends with`, and `does not end with` whenever the value is a string. Numeric and boolean equality stays exact.

Case-insensitive matching applies wherever contextual conditions are evaluated, including merchandising rules, request transforms, sort orders, and block rules.

## Overlap detection

When you create or edit contextual conditions in the dashboard, Layers automatically checks whether your conditions overlap with another merchandising rule targeting the same collection and sort order. If an overlap is detected, a warning toast appears with the name of the conflicting rule and a link to view it.

Two rules overlap when their conditions could match the same visitor session. For example, two rules that both target the same country or use a "contains" check that matches a subset of the other rule's values.

Overlap detection helps you avoid situations where a visitor could match multiple conditional rules unexpectedly. If you see an overlap warning, review both rules to confirm the intended priority or adjust the conditions to make them mutually exclusive.

## Use cases

**Geographic merchandising**: Show region-specific products or promotions based on visitor location.

**Market-specific merchandising**: Apply different product arrangements per Shopify Market, so shoppers in your EU market see a different collection grid than shoppers in your North America market.

**Campaign-specific merchandising**: Display different product arrangements for visitors arriving from specific marketing campaigns.

**Device-optimized merchandising**: Adjust product ordering based on device type for optimal mobile or desktop experiences.

**Customer segment targeting**: Show VIP customers different merchandising than first-time visitors.

## See also

* [Merchandising Rules](/platform/merchandising)
* [Multiple Rules per Collection](/platform/merchandising/multiple-rules)
* [Rule Scheduling](/platform/merchandising/scheduling)
* [Contextual Information](/engine/contextual-information/data-structure)
