Skip to Content
FeaturesVariants

Variants

Variants let you serve different content to different audiences from the same record. Show mobile users a simplified layout, VIP users exclusive offers, or regional users localized promotions — all without duplicating records.

Overview

A variant is an alternative version of your content that displays when certain targeting conditions are met. Each record can have multiple variants:

Homepage -- Default variant (shown to everyone else) -- Mobile variant (simplified for small screens) -- VIP variant (exclusive offers) -- Holiday variant (seasonal content)

When a visitor requests content, Foir evaluates each variant’s targeting rules, which come from the variant catalog entry it references, against the provided context (device, segment, market, etc.). Among the variants that match, the highest priority wins. If none match, the default variant is used.

Variants are only available on models with the variants capability enabled.

Key Concepts

  • Default variant — Every record has a default variant that acts as the fallback when no other variant matches
  • Targeting rules — Conditions that determine when a variant is shown (device type, authentication status, custom contexts)
  • Priority — A numeric value that controls evaluation order; higher priority variants are checked first
  • Independent publishing — Each variant has its own publishing state and version history

Three Levels of Variation

Variants apply at three levels of granularity. Use the smallest level that gets the job done:

LevelWhat variesExample
Page-levelThe entire record. Different fields, different structure, different everything.A French homepage with a completely different layout from the English one.
Field-levelThe composition inside one prose field. Same record, but different entries or a different order.The mobile variant drops the feature grid; the holiday variant places an extra promo.
Entry-levelThe data inside one entry of a prose field. Same overall structure, different content per audience.The hero’s headline and CTA copy change per market or locale.

Entry-level variants are the most useful for translation: the skeleton of the document stays the same across locales, while every passage, headline and CTA label varies independently. Every entry of a resolved flow — placed models and passages alike — is a variantable unit, so you do not duplicate a whole document to change one paragraph.

An entry-level variant swaps a whole entry’s value; it does not subset the fields inside one. An entry is a unit — to vary one member of a placed model, swap the entry.

In the console

Creating a variant

  1. Open any record that belongs to a model with variants enabled
  2. Open the editor’s Variants tab
  3. Click Add Variant
  4. Pick the variant catalog entry the variant is for (for example “Mobile Users”). The variant takes its key, targeting and priority from the entry, so create the entry first if it does not exist
  5. Edit the variant’s content
  6. Publish when ready

Using the Variant Catalog

Every variant references a catalog entry, and the entry is where its targeting rules and priority are defined:

  1. Go to Settings > Variant Catalog
  2. Create reusable targeting rules (e.g., “VIP Users”, “Mobile Users”)
  3. When creating a variant, pick the entry

See Variant Catalog for details.

Targeting Rules

Targeting rules determine which variant to show. Rules are built from conditions that can be combined with AND/OR logic.

Available conditions

Device and Platform

  • Device is mobile, tablet, or desktop
  • Platform is web, iOS, or Android

Authentication

  • User is signed in

There is no signed-out condition to pair with it. Forward a user token on the read and the dimension is authenticated; send none and it is absent rather than set to a second value, so no rule can match a signed-out visitor, and the default variant is what serves one. See Targeting.

Custom Contexts (you configure these)

  • Market (UK, US, EU, etc.)
  • User segments (VIP, first-time, returning)
  • Any custom dimension you define

Combining rules

Show to VIP mobile users:

  • Segment is VIP AND Device is mobile

Show to UK or US visitors:

  • Market is UK OR Market is US

Variant Priority

When multiple variants match a request, priority determines the winner: among the variants that match, the one whose catalog entry has the highest priority is served.

VariantPriorityRule
Holiday VIP30Is holiday season AND is VIP
VIP20Is VIP
Mobile10Device is mobile
Default0Served when nothing else matches
PriorityUse Case
50+Override/emergency (temporary promotions, urgent updates)
20-50Specific targeting (VIP users, combined conditions)
10-20General targeting (market-specific, device-specific)
0Default fallback

Publishing Variants

Each variant publishes independently:

  • Edit the VIP variant without affecting the default
  • Publish mobile changes while VIP stays in draft
  • Schedule different variants for different dates

Version History

Each variant maintains its own version history, and each sits under the same plan history window as any other record:

  1. Make changes (auto-saved as draft)
  2. Preview before publishing
  3. Publish when ready
  4. Roll back to a previous version if needed

Via the CLI

List variants for a record

foir records variants rec_abc123

Create a variant

foir records create-variant rec_abc123 --key mobile

--key must be the key of an active entry in the Variant Catalog.

Via the API

Content resolution with contexts

Pass context values on the per-model query to trigger variant resolution. The matching variant’s values are merged directly onto the typed fields — there is no separate resolved sub-object:

query { page( naturalKey: "homepage" locale: "en-US" contexts: { device: MOBILE } ) { _id title hero { heading } } }

device and platform are built-in enum dimensions (DESKTOP/MOBILE/TABLET, WEB/IOS/ANDROID). Custom dimensions you configure (e.g. market) appear as additional fields on contexts. Variant selection happens server-side. Select _variant to see which variant served the record. _resolvedBy and _segments, and contexts: { resolutionTrace: true }, say why, for a key holding targeting:debug.

Use preview: true to resolve against draft content instead of published versions.

The same read through the data client:

const page = await foir.page.findUnique({ naturalKey: 'homepage', locale: 'en-US', contexts: { device: 'MOBILE' }, preview: true, });

contexts takes the same input object, one key per dimension. Variant selection still happens server-side and the resolved values still arrive merged onto the record, with the same _variant, _resolvedBy and _segments fields as GraphQL.

Common Use Cases

Mobile optimization

Create a mobile variant with shorter headlines, fewer images, simplified navigation, and larger tap targets.

Regional content

Create market variants with local currency and pricing, region-specific offers, localized images, and local contact information.

User segments

Create segment variants with VIP-exclusive content, first-time visitor onboarding, returning user promotions, and loyalty tier benefits.

A/B testing

Create test variants with different headlines, alternative CTAs, layout variations, or image options, and serve each to a different segment or context. Foir doesn’t include a built-in traffic-splitting or goal-tracking framework — wire variant exposure to your own analytics to measure results.

Best Practices

  • Always keep a meaningful default variant. It serves as the fallback when no targeting rules match.
  • Keep targeting rules simple. Complex rules are harder to debug and maintain.
  • Define each audience once in the Variant Catalog. Every variant that references the entry gets its updates.
  • Test thoroughly by previewing with different context values before publishing.
  • Use clear variant names and descriptions so your team understands the purpose of each.
Last updated on