Skip to main content

Using segmented metrics in sort orders

Segmented metrics enable automatic personalization of product rankings based on each visitor’s context. When you include a segmented metric in a sort order, the system intelligently selects the most relevant metric value for each visitor without requiring separate sort orders for different audiences.

How it works

When you add a segmented metric to a sort order, the system automatically uses the visitor’s context to select the appropriate metric value. For a visitor from the United States, the system uses US-specific performance data when available. For a visitor from Canada, it uses Canadian data. If segment-specific data isn’t available, the system falls back to the overall value, ensuring all visitors see ranked results. This happens transparently at query time. You configure the segmentation once in your metric and sort order, and the system handles all the complexity of matching visitor context to the right data.

Smoothing factor

The smoothing factor controls how segment-specific and global performance data are blended when ranking products. This parameter helps balance the responsiveness of segment-specific rankings with the stability of global trends. How it works: When a segmented metric is used in a sort order, the system calculates a weighted blend of segment-specific data and global data for each product:
final_score = (segment_value × segment_weight) + (global_value × global_weight)
The smoothing factor (default: 50) determines these weights. Lower values prioritize segment-specific performance, making rankings more responsive to local trends. Higher values blend in more global data, providing stability 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. The system applies this blending automatically 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

Works with other features

Segmented metrics integrate seamlessly with other sort order capabilities:
  • Weighted sorting: Combine multiple segmented metrics with different weights to create sophisticated ranking algorithms
  • 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

Conditional sort expressions

Conditional sort expressions 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.

How it works

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 conditional expressions

  • 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:
FieldDescriptionExample values
geo.countryVisitor’s country codeUS, CA, GB
geo.provinceVisitor’s province or stateCalifornia, Ontario
geo.cityVisitor’s cityLos Angeles, Toronto
Supported operators:
OperatorDescription
eqEquals
neqNot equals
inMatches any value in a list
notInDoes not match any value in a list

Example: geographic-based sorting

A single sort order can apply different sorting strategies based on visitor location:
Expression 1: Sort by price descending
  Condition: geo.country equals "US"

Expression 2: Sort by price ascending
  Condition: geo.country equals "CA"

Expression 3: Sort by title ascending
  (No condition — always applies as fallback)
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 a conditional expression does not match, it is skipped entirely. Always include at least one unconditional expression at the end of your sort order to ensure all visitors receive sorted results. Without a fallback, visitors who don’t match any condition see default ordering.

Works with other features

Conditional expressions 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 conditional expressions alongside segmented metrics for layered personalization
  • Sequences: Conditional 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 using multiple conditional expressions, ensure the conditions are mutually exclusive or ordered by priority to avoid unexpected results

See also