Skip to main content
Fallback chains keep recommendations showing to customers even when the primary block doesn’t return enough products. You build fallbacks as branches: a single branch with no conditions gives every shopper the same ordered chain, and several branches with conditions form a fallback tree that picks a different chain based on visitor context.

How fallback chains work

When a block doesn’t meet its minimum products safeguard, Layers automatically tries fallback blocks in order:
  1. Primary block is evaluated first
  2. If results are below minimum, try Fallback 1
  3. If Fallback 1 also doesn’t meet minimum, try Fallback 2
  4. Continue until a block meets the minimum or all fallbacks are exhausted

Fallback modes

Each block in a fallback chain has a mode:
  • Replace: serve the fallback block’s results instead of the primary block’s results.
  • Fill remaining: keep the primary block’s results and top them up with products from the fallback block until the minimum is met. Layers removes duplicates and respects the maximum products safeguard. If the primary block uses a diversity cap, Layers applies it across the combined results and places within-cap products before products beyond the cap.
Use Fill remaining when the primary returns useful results but needs more products to reach the minimum. The rest of this page calls this mode fill.

Configuring fallback chains

In the block editor’s numbered Fallback section, click Add branch to create a branch. In its When step, choose Everyone or When conditions match and add conditions if needed. In Then try, click Add block to build the ordered chain, and choose a fallback mode for each block. The editor keeps a live preview on the right as you change the block. Use it to check the recommendations produced by your current settings. Important considerations:
  • Fallback blocks must be published. Layers skips draft blocks in a chain
  • Fallback blocks should have the same anchor type as the primary block
  • Fallback blocks must have the same result type as the primary block. A content block can only fall back to other content blocks, and a product block to other product blocks. The dashboard’s fallback builders only offer matching blocks
  • Avoid circular references
  • Fallback blocks can have their own fallback chains
  • Layers prevents infinite loops by tracking visited blocks
  • You can mix fallback modes in the same chain

Fallback trees

A fallback tree lets a single block deliver different fallback chains to different visitors. Instead of one ordered list, you define multiple branches, each with its own set of conditions and its own fallback chain. At request time, Layers evaluates each branch in order and uses the chain from the first branch whose conditions match the visitor’s context. Use a fallback tree when you want fallbacks to vary by audience without creating multiple parallel blocks. For example, you might fall back to a “Best Sellers, US” block for shoppers in the United States and a “Best Sellers, EU” block for shoppers in Europe.

How tree evaluation works

  1. Branches are evaluated in the order they appear in the Fallback section
  2. The first branch with matching conditions wins. Later branches are not evaluated
  3. A branch with no conditions matches everyone, so it acts as the default. The editor labels it Everyone. Place it last
  4. The chain inside the matched branch is then evaluated like a normal fallback chain, in order and using each entry’s fallback mode
  5. If no branch matches and there is no default branch, the block returns no fallback results

Branch conditions

Each branch can target visitors by the same contextual fields used elsewhere on a block: geographic location, customer tags, device type, marketing source, and product attributes when the block has an anchor product. Conditions are combined with AND or OR combinators inside the branch. Conditions are evaluated against the same context object the request was made with, so calls to the Blocks API must pass context and identity fields for branch matching to work. Without context, only the default branch (if any) will match.

Configuring a fallback tree

In the block editor’s numbered Fallback section, click Add branch once for each branch you need. For each branch:
  1. Under When, choose Everyone or When conditions match, then define the conditions that select this branch.
  2. Under Then try, add the fallback blocks in order and choose a fallback mode for each one.
New branches are added to the end of the list. Drag branches to change their order; the first matching branch wins. Put your most specific branches first and the Everyone branch last. The editor warns you when an Everyone branch appears before another branch because later branches will never run.
Existing blocks that use a flat fallback chain are migrated automatically to a tree with a single default branch. No action is required, and the runtime behavior is unchanged.

Example: geographic fallback tree

A US shopper falls back to US-specific blocks, EU shoppers fall back to a regional block, and everyone else gets the global default.

Best practices

Strategy diversity: Use different strategy types in your fallback chain to maximize coverage.
Progressive relaxation: Start with highly personalized strategies and fall back to broader recommendations.
Fill mode for supplementing results: Use fill mode when you want to keep the primary block’s results and top them up with additional products.
Anchor type consistency: Give fallback blocks the same anchor type as the primary block to maintain context.
Minimum products alignment: Set appropriate minimums for each block in the chain.

See also