AI Content Decisioning Agent lets you test multiple versions of your message content and let the system automatically deliver more of what performs best.
This guide will walk you through how to write content variations with the vary() function and add them to your templates across email, SMS, and push.
Step-by-Step: How to Set Up Content Variations
Step 1: Write Your Variation Code
Define each variant using capture, then pass them to vary():
{%- capture SL1 -%}Your weekend offer is here{%- endcapture -%}
{%- capture SL2 -%}Don't miss your Friday bonus{%- endcapture -%}
{%- capture SL3 -%}Exclusive: this week only{%- endcapture -%}
{{ vary([SL1, SL2, SL3]) }}You can define up to 4 variants per tag.
vary() across multiple fields, every tag must have the same number of variants. Variant 1 of the subject always sends with Variant 1 of the preview, and so on.Whitespace Control
If you notice an unexpected blank space at the top of your template, add dashes to your capture tags to remove it. This is called dash syntax — {%- and -%} — and it trims whitespace around the tag.
Adding Personalization
Drop your personalization tag directly inside the capture block:
{%- capture SL1 -%}Hey {{ customer.FIRST_NAME | default: "there" }}, your offer is here{%- endcapture -%}
{%- capture SL2 -%}Don't wait, {{ customer.FIRST_NAME | default: "there" }} — offer ends Sunday{%- endcapture -%}
{{ vary([SL1, SL2]) }}Use | default: "text" to gracefully catch missing attribute values.
Varying Data Connections and Content Blocks
The same pattern works for data connections and content blocks. Add them inside capture blocks. They can be combined with text and other personalization tags if needed.
Data connections:
{%- capture DC1 -%}{{ data_connection('DC_a09f78a7-5b70-4a45-9316-0bf40d150dc4', customer.SUPPORTER, 'Supporter') | default: 'Your Team' }}{%- endcapture -%}
{%- capture DC2 -%}{{ data_connection('DC_b19f78a7-5b70-4a45-9316-0bf40d150dc5', customer.SUPPORTER, 'Supporter') | default: 'Your Team' }}{%- endcapture -%}
{{ vary([DC1, DC2]) }}Content blocks:
{%- capture CB1 -%}{{ content_block('promo-1-nv5kheabuz') }}{%- endcapture -%}
{%- capture CB2 -%}{{ content_block('promo-2-qr7wjdcytx') }}{%- endcapture -%}
{{ vary([CB1, CB2]) }}Step 2: Insert into Your Template
The vary() syntax is the same across all channels. Where you paste it depends on the channel and the field.
Subject line & preview text: Paste your full Liquid block directly into the field. These accept Liquid natively.
Body: For email body content variations, the Liquid is split into two parts.
-
Place your
capturestatements at the top of the template using dash syntax ({%- -%}) so they render invisibly:{%- capture BODY1 -%}Here's a gift to help you bounce back! 🎁{%- endcapture -%} {%- capture BODY2 -%}A special surprise to change your luck! 🎁{%- endcapture -%} {%- capture BODY3 -%}Unlock a trait to get things moving! 🎁{%- endcapture -%} {%- capture CTA1 -%}Claim Your Bonus{%- endcapture -%} {%- capture CTA2 -%}Deposit & Play Now{%- endcapture -%} {%- capture CTA3 -%}Unlock My Gift{%- endcapture -%} {%- capture CTA4 -%}Boost My Balance{%- endcapture -%} -
Place the
vary()snippet into each body component you want to vary:{{ vary([BODY1, BODY2, BODY3, BODY4]) }} {{ vary([CTA1, CTA2, CTA3, CTA4]) }}
This keeps your template clean — the variable definitions sit out of sight at the top, and only the short vary() snippet goes into the component you're varying.
SMS
Message text: Paste your Liquid block into the message text field in the SMS template editor.
Push Notifications
Title and/or body: Paste your Liquid block into the title field, the body field, or both. If varying both, the 1:1 rule applies — same number of variants in each field.
Step 3: Validate, Preview, and Test
-
Validate. The Template Editor automatically checks for syntax errors when you save. It will also scan the template to ensure that the number of content variants is consistent throughout. If personalization tags aren't rendering, check for any validation errors and confirm you are using a Liquid template.
Note: If your variation includes a content block, preview all variants to ensure it renders correctly. You can also check validation for content blocks in the Content Studio editor. -
Preview. Click Preview in the Template Editor. Click the refresh button to view a different variation at random.
To view a specific template variation, update eachvary()to select a single variable from the array. - Test Send. Send a test to cycle through your variables, testing each template variation individually.