Skip to main content

Overview

A weighted group blends several attributes and metrics into a single sort score so collection pages can balance multiple signals at once. Each feature you add contributes a configurable share of the final score, and you choose whether higher or lower values are better on a per-attribute basis. Use a weighted group when no single attribute captures what you want to rank by — for example, when you want to balance sales performance with freshness, or recency with margin. A weighted group reflects a strategy (“60% sales, 40% new arrivals”) rather than a strict hierarchy.

How weighted groups work

Inside the group you add expressions (attributes and metrics). For each expression you set:
  • A weight, expressed as a share of 100. Layers automatically normalizes weights so they sum to 100 — dragging one slider rebalances the others proportionally, so the share you see is the share each feature actually contributes.
  • A preference (attribute expressions only): Higher is better or Lower is better. Metric expressions default to higher is better.
For each product, Layers normalizes every feature’s value across the current result set to a 0–1 range, signs it by your preference, multiplies by the weight, and sums the terms into one score. Result-set scoping means the normalization adapts to whatever the shopper is looking at. A “freshness” feature is compared against the products in the active collection or search, not against your entire catalog — so the blend stays meaningful inside small collections. The group’s Final Sort Direction controls how products are ordered by the resulting score. Most weighted groups use descending (highest blend score first); set it to ascending only when you want the lowest blend score on top.

When to use a weighted group

A weighted group is the right tool when you want to combine signals into one ranking rather than apply them in priority order. Reach for it when:
  • One metric isn’t enough — for example, “best-selling and new”.
  • You want to soften a single dominant signal by mixing in a secondary one.
  • You want to expose a blended ranking as its own storefront sort option (for example, “Best match”).
If instead you want products matching a condition to cluster at the top or bottom, use priority rules. If you want to lift matching products into view without clustering, use soft boost.

Configuration

In the sort order editor, click Add Expression and choose Weighted Groups. A new group is created with one feature row to start.

Add expressions to the group

Use the picker to add attributes or metrics. Each row supports:
  • Feature — the attribute or metric to contribute.
  • Preference (attributes only) — Higher is better or Lower is better.
  • Weight — the share of the blend, on a slider out of 100.
  • Bucket (date attribute rows only) — Hour, Day, Week, Month, Quarter, Year, or No bucket. Rounds the date down to the start of the chosen period before it contributes to the blend. Use a coarser bucket when a raw timestamp gives the date feature too much sway inside the group — for example, so products released in the same week compete on their other features instead of splitting on release minute.
You can remove a feature row at any time; the remaining weights rebalance to keep the total at 100. A group can contain a single feature, though the blend is most useful with two or more.

Pick a metric

The metric picker groups your metrics into sections so the list stays scannable as your metric library grows:
  • Recently used — the three metrics you most recently added to a sort order float to the top for quick reuse.
  • Sales and revenue, Engagement, Events, Rate, Other — the rest of your metrics, grouped by what they measure and sorted alphabetically within each section. The Rate section holds ratio measures like click-through rate, add-to-cart rate, hover rate, and touch rate.
Each row labels the metric with a name derived from the metric’s underlying query (for example, “Total sales by state/province (30d)”), and shows a source badge so you can tell LayersQL metrics apart from imported ones at a glance. Segmented metrics are marked with a · segmented suffix.

Create a metric without leaving the sort order

If you can’t find the metric you need, click Create metric… at the bottom of the picker to open an inline Create metric dialog. It skips the trip to the Metrics dashboard so you can add a signal to the sort order in one flow. The dialog has three panes:
  • Measure — what to count, grouped by the same sections as the picker (Sales and revenue, Engagement, Events, Rate, Other). Each measure shows either its aggregation (such as sum or count) or a blended badge for attributed measures.
  • Group by and Time window — the level each value is rolled up to (Product, Variant, Combined listing, or a custom product attribute) and the range it covers. Grouping levels your store can’t use appear disabled, with a tooltip explaining what’s missing. For example, Combined listing is only available when your catalog has combined-listing products. Grouping by a product attribute (Combined listing or a custom attribute like vendor or style code) rolls the measure up to the attribute value: every product sharing the same value reports the group’s combined total, not its individual contribution. Group by Product or Variant when you want per-product or per-variant scores instead.
  • Threshold — an optional minimum-data rule that drops groups with too little activity to rank fairly. A threshold has three parts: a metric to check against, a comparison, and a value. You can pick any measure the query offers, plus the denominators of rate measures. Comparisons are ≥ at least, > more than, ≤ at most, or < fewer than. For example, keep only products with at least 500 impressions holds new products with a single click from leapfrogging a proven bestseller. Click Add a minimum to open the row; the dialog counts what the rule drops from the current preview (“Drops 7 of 12 products with fewer than 500 impressions”) so you can tune the value before saving. Rate measures like click-through rate or hover rate require a threshold — the dialog seeds one on the rate’s denominator (default 100, editable) as soon as you pick the measure. Count and sum measures don’t require a threshold, but you can still add one when you want to hold out low-volume groups.
  • Segment by — optional dimensions that split the metric further. Order matters: each level splits the one above it.
A live Preview pane shows the top rows the metric would produce with the current settings, so you can sanity-check the shape before saving. Each row is labeled with the product title, and — when the grouping repeats a product across several rows — the variant name, family name, or attribute value that row rolls up to appears underneath. Save the metric and the picker refreshes with the new metric already selected in the row. You need permission to edit analytics to create metrics from the picker. Without it, the Create metric… action is hidden and you can only pick from existing metrics.

Metric data status

Each metric row shows a compact status badge next to its title so you can tell whether the metric is ready to score by:
  • Loading (amber) — the metric’s data is still being computed. The row is savable; the sort order will start using the metric as soon as data is ready.
  • No data (red) — the load finished but produced nothing to score by (for example, the time window has no matching events). The row explains why and offers a retry.
No badge means the metric has data and is scoring products normally.

Group settings

The group header has a settings (gear) icon that opens a sheet with:
  • Final Sort Direction — Descending (default, highest score first) or Ascending.
  • Conditions — optional contextual conditions that gate the entire group by request context (device, market, applied filters, and so on). When the conditions don’t match the current request, the whole weighted group is skipped and the next expression in the sort order takes over.
  • Only when… — optional per-product gate on the whole blend. Products that fail the gate get no blend score and fall through to the next expression in the sort order. See conditional sort expressions for the full behavior.
The header also shows a Blend preview on hover: a donut visualization of how the configured weights divide up the final score, with each feature colored to match its row.

Gate individual features

Each feature row inside the group also supports its own Only when… condition. Use it to say “only let this signal count when the product qualifies” without gating the whole blend. When a product fails a feature-level gate, that feature contributes 0 to the blend for that product and is excluded from its own 0–1 normalization window — so the remaining features rank the product on their own terms, and normalization for the gated feature isn’t skewed by products that shouldn’t have been in the pool. Common uses:
  • Confidence-scope a noisy feature. Blend conversion rate at 40% and sales at 60%, but only let conversion rate count for products with enough orders for the number to be reliable.
  • Attribute-scope a metafield feature. Give an editor-curated score weight only for the products that actually carry it.
Products under the order threshold rank on Sales alone; products above it rank on the full 60/40 blend. Feature-level gates are independent of the blend-level Only when… — a product must satisfy both to score on that feature within a blend.

Compose with soft boost or User Affinity

A weighted group is a first-class base in the sort pipeline, so you can layer modifiers on top of its score:
  • Drop a soft boost below the weighted group to lift products matching a condition within the blended ranking.
  • Drop User Affinity below the weighted group to personalize the blend for each shopper.
The modifiers attach to the weighted score the same way they would attach to a single attribute or metric. This lets you build sort orders like “blend 70% sales + 30% margin, then softly lift in-stock products” without rebuilding the blend itself.

Observability

Weighted groups participate in the same instrumentation as other sort types:
  • Score breakdown — open the Lab view for a product to see the active feature contributions and their normalized values.
  • Annotations — sort effect annotations show when the weighted group drove a product’s position.
See Preview and annotations for the full set of tools.

Best practices

  • Start with two features. Bigger blends are harder to reason about; add a third feature only when it noticeably changes the ranking.
  • Keep weights meaningful. A feature weighted under ~10% rarely changes the order — either raise it or drop it.
  • Pick the right preference. Use Lower is better for fields like price when shoppers want cheaper items first, or distance for store-locator sorts.
  • Use conditions to scope the blend. If a blend only makes sense for a subset of traffic (a market, a channel), set group conditions instead of duplicating sort orders.
  • Preview before publishing. Open the sort order preview and compare a collection with and without the group to confirm the blend produces the order you expect.

See also