> ## 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.

# Blocks

> Configurable product recommendation widgets that surface personalized suggestions based on shopper behavior, product similarity, or curated collections.

## Overview

Blocks display product recommendations across your storefront. Unlike static product lists, blocks generate recommendations dynamically based on context, customer behavior, and configurable rules.

**Key capabilities:**

1. **Multiple anchor types** — Display recommendations on product pages, blog articles, collection pages, the cart, the home page, search pages, 404 pages, landing pages, and custom surfaces
2. **Flexible strategies** — Choose from interaction, similarity, manual, metafield reference, set, personalized, trending, contextual, and related content strategies
3. **Cross-content recommendations** — Recommend products from blog articles, or related articles and pages from product, cart, and article surfaces
4. **Conditional rules** — Modify block behavior based on customer context and product attributes
5. **Safeguards** — Keep blocks displaying appropriately with minimum/maximum constraints
6. **Fallback chains and trees** — Automatically use alternative blocks (or different chains for different audiences) when primary blocks don't return enough products
7. **Inline performance metrics** — See 7-day impressions, clicks, CTR, add-to-carts, and purchases for each block directly in the dashboard list
8. **Live preview** — Test a block's configuration against real catalog data and shopper context before saving

## Anchor types

Anchor types determine where a block appears on your storefront and what context it uses to generate recommendations.

### Strategy availability

Strategy availability depends on the anchor type. Home, not found, and other anchors allow manual, personalized, and trending strategies. Search and landing anchors also allow contextual strategies. None anchors support manual strategy only.

You pick the strategy on the block editor's **Product Source** card, which shows only the settings that apply to the strategy you choose. The anchor type is locked once a block is created, but you can change the strategy on an existing block at any time. Switching strategies resets that strategy's settings to their defaults. Reselecting the current strategy keeps your settings, and your safeguards, rules, and fallback chain are never touched. When you change the strategy, the editor reminds you that the block's recent performance numbers still include the previous strategy.

### Product anchor

Display recommendations on product pages. The block uses the current product as the anchor to find related products.

**Common use cases:**

* "Frequently Bought Together" on product pages
* "Customers Also Viewed" recommendations
* "Similar Products" suggestions
* "Complete the Look" cross-sells
* "Wear it with" rails driven by reference metafields authored in Shopify
* "Shop the look" sets built from the companion garments detected in your product photography

### Article anchor

Display recommendations on blog article pages. Select **Blog Article** as the anchor type in the block editor. The block uses the current article as the anchor. Pass the article's numeric ID or Shopify GID as `anchor_id` on the [Blocks API](https://docs.uselayers.com/api-reference/blocks.md) request.

Article anchors can recommend products or content:

* [Shop the Article](https://docs.uselayers.com/platform/blocks/strategies.md#shop-the-article) surfaces the products linked in the article body first, then fills with products similar to the article's content.
* [Related Reading](https://docs.uselayers.com/platform/blocks/strategies.md#related-content-strategy) surfaces other articles or pages related to the current article.
* Manual, personalized, and trending strategies are also available.

**Common use cases:**

* "Shop this story" rails under a blog post
* "Keep reading" rails that link to related articles
* Trending or curated product rails on editorial content

### Collection anchor

Display recommendations on collection pages. The collection is determined dynamically from the `anchor_id` parameter in the API request, which can be either a collection ID or handle.

**How it works:**

* The collection is resolved at request time using the `anchor_id` parameter
* No collection selection is required in the dashboard
* Supports both collection IDs (numeric) and handles (string)

**Common use cases:**

* "Browsed Then Bought" — products purchased by shoppers who browsed the collection
* "Trending in Collection" — products trending within the collection
* Similar products based on the collection's catalog
* Featured products within a collection
* "Editor's Picks" for specific collections
* Collection-specific promotions

### Cart anchor

Use a **Cart** anchor to display recommendations in the cart. Layers considers every product in the shopper's cart, not just the first, when finding complementary items.

Your block rules and conditional fallback branches that check the anchor product evaluate each product in the cart. If any product meets the conditions, Layers applies the rule or branch.

**Common use cases:**

* "Complete the Look" in cart
* "Frequently Bought Together" based on cart contents
* Cross-sell recommendations before checkout

### Home anchor

Display recommendations on the storefront home page. The block has no anchor product or collection, but trending strategies can use store-wide activity to populate results.

**Common use cases:**

* "Best sellers" and "Trending now" rails
* "Popular in your area" region-aware rails
* Manually curated "Featured products" hero

### Search anchor

Display recommendations on search results pages. The current search query is passed in via the API request context and powers query-aware contextual strategies.

**Common use cases:**

* "Shoppers also viewed" alongside search results
* "Top picks for this search" conversion rails
* Recovery rails on zero-result searches

### Not found anchor

Display recommendations on 404 pages so a missing URL becomes a discovery moment instead of a dead end.

**Common use cases:**

* "You may also like" fallback on 404s
* "Best sellers" or "Trending now" to keep shoppers in the funnel
* Recently viewed re-engagement

### Landing anchor

Display recommendations on campaign landing pages. The traffic source (UTM parameters, marketing channel) is passed in via the request context and can drive contextual strategies.

**Common use cases:**

* Channel-aware "Top picks for this campaign" rails
* Trending rails for launch and promo pages
* Manually curated hero blocks on paid traffic destinations

### Other anchor

Display recommendations on custom storefront pages that don't fit the standard surfaces, such as about pages, blog posts, and custom routes.

**Common use cases:**

* Trending rails on editorial content
* Cross-sell blocks on app or custom pages
* Manually curated placements outside the main funnel

### None anchor

Global blocks that can appear anywhere on your storefront. None-anchor blocks require no anchor context and support the manual strategy only.

**Common use cases:**

* Hand-picked "Featured products" on static pages
* Manually curated rails embedded in custom templates

## Result types

Every block has a **result type** that determines what it returns:

* **Products** (default) — The block returns product recommendations. All strategy types except related content use this result type.
* **Content** — The block returns blog articles or pages instead of products. Content blocks use the [related content strategy](https://docs.uselayers.com/platform/blocks/strategies.md#related-content-strategy) and are available on product, cart, and article anchors.

The dashboard derives the result type from the strategy you pick, so you never set it directly. Content blocks skip product-only controls: the block editor hides product filters, the hide out of stock safeguard, and the diversity cap. [Fallback chains](https://docs.uselayers.com/platform/blocks/fallback-chains.md) can only reference blocks with the same result type.

## Block preview

The block editor includes a **Live Preview** panel that runs the block's current configuration against your live catalog without saving. Use it to:

* Sanity-check anchor selection by entering a real product or collection ID. For product anchors, you can also select a specific variant so variant-aware strategies (like a variant-scoped [metafield reference](https://docs.uselayers.com/platform/blocks/strategies.md#metafield-reference-strategy) block) resolve against that variant.
* Simulate visitor context by picking a [demo profile](https://docs.uselayers.com/help/evaluate/test-text-search.md#create-a-demo-profile-persona). Geography, prior searches, cart contents, past purchases, marketing source, and shopping channel all flow into the preview.
* Compare different strategy and safeguard combinations before publishing

The preview returns the same results the [Blocks API](https://docs.uselayers.com/api-reference/blocks.md) would return for the configured anchor and context, including any active rules and safeguards. For content blocks, the panel renders article and page cards instead of product tiles. The preview also runs your unsaved **Fallback Branches**: when the primary block is hidden by a rule or returns fewer than its minimum products, the panel shows what the matching fallback serves. Fallback blocks run with their saved configuration.

You can also preview blocks through the [Layers MCP server](https://docs.uselayers.com/developers/mcp-servers.md#previewing-blocks) with the `blocks-preview` tool. Previewing a saved block over MCP runs the full pipeline, including the fallback chain. It can also return a step-by-step execution trace showing which rules matched and why products were included or excluded.

Contextual, trending, and personalized strategies use the selected demo profile to drive real results in the preview. `trending_in_region` reads geography. `searched_then_viewed` and `searched_then_purchased` read prior searches. `landing_page_picks` reads the marketing source. Personalized strategies read cart and purchase history. If the profile doesn't provide the signal a strategy needs, the preview returns empty, matching what a live request would show.

### Data-is-computing state

Trending and contextual strategies depend on periodic rollup data. When a strategy is still building its first rollup (for example, on a newly connected store or right after a strategy is enabled), the dashboard surfaces this in three places:

* The **Strategy** selector in the block editor shows a "Strategy data is being computed" notice next to any strategy whose data isn't ready yet.
* The **Live Preview** panel returns a "Data is being computed" state instead of running the strategy, and notes that live requests will use the block's [fallback chain](https://docs.uselayers.com/platform/blocks/fallback-chains.md) until training completes.
* The **Recommendation Blocks** list reflects this in the **Published** column. A published block shows a **Publishing** badge with a spinner while its strategy data is still computing, then returns to **Published** once the data is live. The **Publishing** badge shows which blocks are running on fallbacks.

If a rollup fails, the same surfaces show a "computation failed" notice and the block's **Published** badge shows **Failed**; the job is retried automatically.

## Inline performance metrics

The blocks list shows a 7-day rolling performance summary for each block, refreshed every four hours:

* **Impressions** — number of times the block was rendered (block requests)
* **Clicks** — distinct product views attributed to the block
* **CTR** — clicks ÷ impressions
* **Add to cart** — distinct add-to-cart events attributed to the block
* **Purchases** — distinct purchases attributed to the block

A small sparkline next to each row shows the daily trend across the last seven days. The same metrics are available on merchandising rules. See [Metrics](https://docs.uselayers.com/platform/metrics.md) for how attribution works.

> [!NOTE]
>
> Metrics rely on the [attribution token](https://docs.uselayers.com/api-reference/blocks.md#response) returned by the Blocks API and forwarded to the [Beacon API](https://docs.uselayers.com/tracking-api/send-events.md). Make sure your storefront forwards click, add-to-cart, and purchase events with the block's `attributionToken` for these counts to populate.

## Performance details

Click any row's performance summary on the **Recommendation Blocks** list to open the **Performance** sheet for that block. The **Performance** sheet shows how the block converts and which products drive its results.

The **Performance** sheet has these sections:

* **KPI cards** — Impressions, CTR, add-to-cart rate, purchase rate, revenue, and revenue per impression (RPI). Each card shows the absolute value and the percent change versus the prior period of the same length.
* **Trend** — A combined line/bar chart showing impressions, clicks, add-to-carts, and purchases across the selected timeframe. Use it to spot day-of-week patterns or campaign spikes.
* **Position** — A breakdown of how the block performs by slot position. Use it to see whether top-positioned products carry the conversion or if engagement spreads evenly across the carousel.
* **Top products** — The products that drove the most impressions, clicks, and revenue for the block. Each row shows the product title alongside its individual performance metrics.

Use the date range and compare-to pickers at the top of the sheet to change the timeframe and comparison period, and the **Revenue** picker to choose **Blended** or **Full credit** revenue. Below the position chart, the **Products** tab lists the block's products and the **Breakdown** tab splits results by dimensions such as device, country, or channel. See [Performance panel](https://docs.uselayers.com/platform/metrics.md#performance-panel).

Click, add-to-cart, and purchase totals on the KPI cards are **blended**. They combine events forwarded with the block's `attributionToken` and modeled events from the same browsing session, which count only when the shopper clicked the same product from the block earlier in the session. The KPI cards expose the deterministic-versus-modeled split so you can see how much of each metric came from each signal. See [Metrics: Blended attribution](https://docs.uselayers.com/platform/metrics.md#blended-attribution) for the full breakdown.

> [!NOTE]
>
> The performance sheet uses the same attribution data as the inline metrics. If your storefront isn't forwarding the `attributionToken` to the [Beacon API](https://docs.uselayers.com/tracking-api/send-events.md), the **Performance** sheet shows empty results.

## Bulk actions

The **Recommendation Blocks** list supports multi-select for fast cleanup, audits, and seasonal launches:

1. Click **Select** in the actions column header to enter selection mode.
2. Tick the checkbox on each block you want to act on. Hold **Shift** and click another checkbox to select every row in between.
3. Open the **Actions** dropdown and select one of the bulk actions:
   * **Publish** — Activate every selected draft block at once.
   * **Unpublish** — Move every selected active block back to draft so it stops returning results, without losing your configuration.
   * **Duplicate** — Create a draft copy of each selected block named `<title> (Copy)`. Duplicates always start as drafts so they never accidentally go live.
   * **Delete** — Permanently remove the selected blocks. A confirmation dialog appears before the deletion runs.

Click **Actions** → **Done selecting** to exit selection mode.

> [!TIP]
>
> Use **Shift+click** on rows when you want to flip a long range of blocks between published and draft for a campaign, such as unpublishing every clearance block at the end of a sale.

## See also

* [Strategies](https://docs.uselayers.com/platform/blocks/strategies.md) - Strategy types and availability by anchor type
* [Rules & Safeguards](https://docs.uselayers.com/platform/blocks/rules-and-safeguards.md) - Conditional rules, safeguards, and fallback chains
* [Fallback Chains](https://docs.uselayers.com/platform/blocks/fallback-chains.md) - Simple chains and conditional fallback trees
* [Priority & Status](https://docs.uselayers.com/platform/blocks/priority-and-status.md) - What block priority does and the block lifecycle
* [Manage blocks in bulk](https://docs.uselayers.com/help/blocks/bulk-actions.md) - Publish, duplicate, or delete several blocks at once
* [View block performance](https://docs.uselayers.com/help/blocks/view-performance.md) - Open the performance sheet for a block
* [Blocks API Reference](https://docs.uselayers.com/api-reference/blocks.md) - API documentation for retrieving block products
