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 variants with assign, then pass them to vary():
{%- assign SL1 = "Your weekend offer is here" -%}
{%- assign SL2 = "Don't miss your Friday bonus" -%}
{%- assign SL3 = "Exclusive: this week only" -%}
{{ vary([SL1, SL2, SL3]) }}You can define up to 4 variants per tag.
Whitespace Control
If you notice an unexpected blank space at the top of your template, add dashes to your assign tags to remove it. This is called dash syntax — {%- and -%} — and it trims whitespace around the tag.
Adding Personalization
Personalization can't be added directly to your list of variations. Build it as a separate variable first, or use the append filter, then include that variable in your variation list:
{%- assign name = customer.FIRST_NAME | default: "there" -%}
{%- assign SL1 = "Hey " | append: name | append: ", your offer is here" -%}
{%- assign SL2 = "Don't wait, " | append: name | append: " — offer ends Sunday" -%}
{{ vary([SL1, SL2]) }}Use | default: "there" to gracefully catch missing attribute values.
Incorrect — this will NOT resolve:
{{ vary(["Hey {{ customer.FIRST_NAME }}", "Weekend offer inside"]) }}vary() supports plain text strings and customer attributes only. Support for content blocks and data connections are coming soon.The 1:1 Rule (Linked Fields)
When you use 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.
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
assignstatements at the top of the template using dash syntax ({%- -%}) so they render invisibly:{%- assign BODY1 = "Here's a gift to help you bounce back! 🎁" -%} {%- assign BODY2 = "A special surprise to change your luck! 🎁" -%} {%- assign BODY3 = "Unlock a trait to get things moving! 🎁" -%} {%- assign BODY4 = "Enjoy a little boost to turn your day around! 🎁" -%} {%- assign CTA1 = "Claim Your Bonus" -%} {%- assign CTA2 = "Deposit & Play Now" -%} {%- assign CTA3 = "Unlock My Gift" -%} {%- assign CTA4 = "Boost My Balance" -%} -
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
Instructions:
- 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.
-
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.
Tagging Your Template
Add a uniform prefix to the template name whenever it includes vary():
[CVO] Weekend Sale — Reactivation
You can then search or sort on [CVO] in the template library and in the Mission Control campaign list to pull up every content optimization campaign in one view.
Requirements
- Email templates must be Liquid-enabled.
- Insert up to 4 variants per
vary()tag. - All
vary()tags must have the same number of variants across the template. - A
vary()tag cannot contain content blocks or data connections. - SMS requires a tracked link for optimization to work.
- Any template containing
vary()is auto-tagged as a content optimization template — there is no setting to enable.
Next: Launch your campaign — see Sending a Campaign with Content Variations.