Skip to main content

Using segmented metrics in sort orders

Segmented metrics personalize product rankings automatically based on each visitor’s context. When you include a segmented metric in a sort order, Layers selects the most relevant metric value for each visitor, so you don’t need separate sort orders for different audiences.

How segmented metrics work in sort orders

When you add a segmented metric to a sort order, Layers uses the visitor’s context to select the matching metric value. For a visitor from the United States, Layers uses US-specific performance data when available. For a visitor from Canada, it uses Canadian data. If segment-specific data isn’t available, Layers falls back to the overall value, so every visitor still sees ranked results. Layers selects the segment value at query time. You configure the segmentation once in your metric and sort order, and Layers matches each visitor’s context to the right data.

Smoothing factor

The smoothing factor controls how segment-specific and global performance data are blended when ranking products. The smoothing factor balances the responsiveness of segment-specific rankings with the stability of global trends. How the smoothing factor works: When a segmented metric is used in a sort order, Layers calculates a weighted blend of segment-specific data and global data for each product:
The smoothing factor (default: 50) determines these weights. Lower values prioritize segment-specific performance, so rankings respond faster to local trends. Higher values blend in more global data, which keeps rankings stable when segment data is sparse or noisy. Choosing a value:
  • 1-50 (Segment-focused): Use when you have sufficient data in each segment and want rankings to closely reflect segment-specific performance. Best for high-traffic stores with established regional patterns.
  • 50-100 (Balanced): The default range balances segment-specific insights with global trends. Suitable for most use cases where you want personalization without excessive volatility.
  • 100-200 (Global-focused): Use when segment data is sparse or when you want rankings to remain stable across segments. Best for new stores, low-traffic segments, or when testing segmentation.
Example scenarios:
  • Geographic segmentation with high traffic: Set smoothing factor to 25-50 to prioritize country-specific performance data
  • Marketing channel segmentation with limited data: Set smoothing factor to 100-150 to blend channel-specific trends with overall performance
  • New segment with minimal data: Set smoothing factor to 150-200 to rely primarily on global performance until segment data accumulates
You can configure the smoothing factor when adding a segmented metric to a sort order. Layers applies the blend at query time for each visitor.

Benefits

Segmented metrics in sort orders deliver more relevant product rankings to different audiences:
  • Geographic relevance: Products that perform well in a visitor’s country or region rank higher for that visitor
  • Channel optimization: Visitors from paid ads see rankings optimized for paid traffic, while organic visitors see organic-optimized rankings
  • Automatic adaptation: Rankings adjust to each visitor without manual intervention or duplicate sort orders

Segmented metrics with other sort features

Segmented metrics work with other sort order features:
  • Weighted sorting: Combine multiple segmented metrics with different weights in one blended ranking
  • Conditional rules: Apply segmented metrics only when specific conditions are met
  • Priority rules: Use segmented metrics alongside boost and demote logic for fine-tuned control

Learn more

Use the sort-order preview to test Session Type and Customer Type segments, including segments inside weighted groups. For each dimension, choose Any, New, or Returning to set the preview context.

Targeting conditions

Targeting conditions let you apply sorting rules only when specific contextual conditions are met. Instead of creating separate sort orders for different audiences, you attach conditions directly to individual sort expressions so they activate dynamically based on visitor context. In the sort order editor, click Add targeting on an expression to open the Targeting Conditions panel.
Targeting conditions are evaluated once per request, against the visitor’s context. They’re different from conditional sort expressions, which use an Only when condition to gate an expression product by product.

How targeting conditions work

Each sort expression in a sort order can include a conditions object. When conditions are present, the expression is only applied if the visitor’s contextual data matches. If conditions are not met, the expression is skipped and the next expression in the list takes effect. Conditions use a combinator (and / or) with one or more rules that evaluate against contextual data fields such as geographic location, marketing channel, or customer segment.

When to use targeting conditions

  • Regional sorting: Sort by price ascending for one country and by popularity for another, all within a single sort order
  • Channel-specific ranking: Apply different sorting logic for visitors arriving from paid ads vs. organic traffic
  • Seasonal targeting: Activate promotional sorting expressions only for visitors in specific regions during local events

How conditions are evaluated

Conditions follow a combinator + rules structure:
  • combinator: and (all rules must match) or or (any rule must match)
  • rules: Each rule specifies a field, operator, and value
Available fields correspond to the contextual data passed with each request. See Contextual information for the full list of supported fields. Common condition fields:
When you select values for geo.country or geo.province in the dashboard, Layers shows the full country or state name next to the ISO code (for example, United States of America (US) or California (CA)). You can search by either the code or the name, so both united and US match the same option. Conditions still evaluate against the ISO code, so rules and contextual payloads stay unchanged.
Supported operators:

Example: geographic-based sorting

A single sort order can apply different sorting strategies based on visitor location:
Result:
  • Visitors from the US see products sorted by price, highest first
  • Visitors from Canada see products sorted by price, lowest first
  • Visitors from all other countries see products sorted alphabetically

Fallback behavior

When an expression’s targeting conditions don’t match, the expression is skipped entirely. Always include at least one unconditional expression at the end of your sort order so every visitor receives sorted results. Without a fallback, visitors who don’t match any condition see default ordering.

Targeting conditions with other sort features

Targeting conditions combine with all other sort order capabilities:
  • Priority rules: Attach conditions to priority rules to promote or demote products only for specific audiences
  • Soft boost: Apply conditional soft boosts that activate based on visitor context
  • Segmented metrics: Use targeting conditions alongside segmented metrics for layered personalization
  • Sequences: Targeted expressions respect product sequences when enabled

Best practices

  • Always include a fallback: End your sort order with an unconditional expression so every visitor sees sorted results
  • Keep conditions simple: Use one or two rules per condition to maintain readability and predictability
  • Test with preview: Use the sort order preview with different contextual data to verify each condition produces the expected results
  • Avoid overlapping conditions: When several expressions carry targeting conditions, make the conditions mutually exclusive or ordered by priority to avoid unexpected results

Per-product “Only when” conditions

While targeting conditions gate a sort expression by visitor context, an Only when condition gates it by per-product data: a product’s own metric value or attribute. Products that don’t match still appear in results; they fall through to the next expression for ranking. An expression can carry both, and both must be satisfied for it to apply. For setup, examples, and best practices, see Conditional sort expressions.

See also