Skip to main content

New Introducing the Holiday Hub — seasonal templates and ideas to plan your holiday campaigns in one place.Introducing the Holiday Hub.Explore the Holiday Hub

Using Liquid Markup in emails

All plans Last reviewed

Liquid Markup lets one email show different content to each recipient based on their entry, such as separate messages for Instant Win winners and non-winners, or for each prize. Copy a snippet from this page into your email content, then test it by entering your published campaign.

What you can do with Liquid Markup

You want toUse this snippet
Show winners and non-winners different messagesWinners and non-winners
Add a closing line everyone seesA message for everyone
Show a prize code to winners onlyPrize code for winners only
Change the message for each prizeA message for each prize or An exact prize
Check for a win, then tailor by prizeA win check with a prize type
Change the message based on a form answerA form answer
Hide a sentence when a field is emptyOnly if a field was filled in
Require two things at onceTwo conditions
Change how a value looks, such as capitals or a dateFilters

Before you start

  • Instant Win snippets need Instant Win turned on in your campaign, and the email connected to the same list as your form. See Instant Win.
  • Prize snippets read the code from a code list. Code lists are included in the Scale plan and higher. See Using unique codes in emails.
  • Comparisons are exact and case-sensitive. GOLD won't match gold, so keep the values in your code list and form consistent.
  • Testing happens on your published campaign. See Test your email.

How Liquid Markup works

Liquid is a templating language created by Shopify. You type it straight into your email content, and every snippet is built from three pieces.

PieceLooks likeWhat it does
Output{{ entry.first_name }}Prints a value, such as a name or prize code.
Logic{% if entry.instant_winner %}Makes a decision, such as showing one message if someone won and another if they didn't.
Filter{{ entry.first_name | capitalize }}Changes how a value looks before it shows.

Logic always uses {% %} and output always uses {{ }}. Don't put an if inside double curly braces, or wrap a merge field in {% %}.

Add Liquid Markup to your email

  1. Start an email as described in Creating autoresponder emails, Creating follow-up emails or Creating scheduled emails.
  2. On the Customize Your Email step, click into a text box and paste a snippet from below.
  3. Replace the sample wording with your own. Insert field names from Available Merge Fields rather than typing them, so they match your form exactly. To insert a prize code, click Prize Code.
  4. Click Continue and finish setting up the email.
  5. Test it before your campaign goes live.

Snippets

Winners and non-winners

Content before {% else %} shows to winners; content after it shows to everyone else.

{% if entry.instant_winner %}
  Congratulations — you won!
{% else %}
  Thanks for playing! No win this time.
{% endif %}

A message for everyone

Anything after {% endif %} shows to every recipient.

{% if entry.instant_winner %}
  You're a winner!
{% else %}
  Better luck next time.
{% endif %}
Thanks for entering {{ entry.tab_name }}.

Prize code for winners only

Non-winners see nothing from this block, so no {% else %} is needed.

{% if entry.instant_winner %}
  Your prize code: {{ entry.prize_codes }}
{% endif %}

A message for each prize

contains checks whether the prize code includes the text. Put a readable prize name in your code list, such as GOLD, so there's something to check. Add an {% elsif %} for each prize.

{% if entry.prize_codes contains "GOLD" %}
  You won the Grand Prize! Details inside.
{% elsif entry.prize_codes contains "SILVER" %}
  Second place — nicely done!
{% else %}
  You won a prize! Your code: {{ entry.prize_codes }}
{% endif %}

An exact prize

When each prize is one exact value, {% case %} is easier to read than a long list of {% elsif %}. {% else %} catches anything not listed.

{% case entry.prize_codes %}
  {% when "FREESHIP" %}
    Enjoy free shipping on your next order.
  {% when "10OFF" %}
    Here's 10% off — applied at checkout.
  {% else %}
    Your reward: {{ entry.prize_codes }}
{% endcase %}

A win check with a prize type

One {% if %} inside another. Each needs its own {% endif %}.

{% if entry.instant_winner %}
  {% if entry.prize_codes contains "TRIP" %}
    Grand prize — you're going on a trip!
  {% else %}
    You won: {{ entry.prize_codes }}
  {% endif %}
{% else %}
  Thanks for playing — no win this time.
{% endif %}

A form answer

For a dropdown or option list. Replace custom_list with your field's name. == means "is exactly", so the text in quotes must match the answer exactly.

{% if entry.custom_list == "Downtown" %}
  Your nearest location is our Downtown shop.
{% elsif entry.custom_list == "Airport" %}
  Your nearest location is our Airport kiosk.
{% endif %}

Only if a field was filled in

The block shows only when the field has a value, so an optional field never leaves a half-empty sentence.

{% if entry.phone %}
  We'll text order updates to {{ entry.phone }}.
{% endif %}

Two conditions

and needs both to be true. Use or if either one is enough.

{% if entry.instant_winner and entry.newsletter == "Yes" %}
  As a winner who's opted in, here's an exclusive offer.
{% endif %}

Filters

Add a filter to a merge field with a |. You can chain several; they run left to right.

FilterWhat it doesExample
default: "there"Shows your text when the value is empty{{ entry.first_name | default: "there" }}
capitalizeFirst letter uppercase, the rest lowercase{{ entry.first_name | capitalize }}
upcaseEverything uppercase{{ entry.prize_codes | upcase }}
downcaseEverything lowercase{{ entry.last_name | downcase }}
date: "%B %d, %Y"Formats a date{{ entry.created_at | date: "%B %d, %Y" }}
truncate: 50Shortens text to 50 characters and adds an ellipsis{{ entry.tab_name | truncate: 50 }}
stripRemoves spaces before and after a value{{ entry.first_name | strip }}
append: "!"Adds text to the end (prepend adds to the start){{ entry.first_name | append: "!" }}

Test your email

  1. Click Send test email to check the layout and wording.
  2. Activate the email and publish your campaign.
  3. Enter the published campaign, on its landing page or where it's embedded, with an email address you can check.
  4. Open the email and check the content matches your entry, such as the winner's or non-winner's message.
  5. When you've finished testing, click Reset Winners in your Instant Win settings. This clears the prizes your test entries won and their "won" labels, so prizes awarded go back to zero before launch. See Making changes to Instant Win.

If something goes wrong

What you seeWhat to do
Markup such as {% if or {{ appears as text, or the email looks brokenA tag is missing its partner. Check every {% if %} has an {% endif %}, every {% case %} an {% endcase %} and every {% unless %} an {% endunless %}, and that logic uses {% %} while output uses {{ }}.
A value is blankThe field name may have been typed by hand and doesn't match the form. Delete it and insert it from Available Merge Fields. If the entrant left the field empty, add a default filter.
Everyone gets the non-winner messageCheck Instant Win is turned on in the campaign, and the email is connected to the same list as your form.
A comparison never matchesComparisons are exact and case-sensitive. Make the text in your markup match the form answer or code exactly, capitals included.

FAQs

Can I check my Liquid Markup with a test email?

A test email is useful for checking the layout and wording. To see the content each entrant actually gets, such as the winner's or non-winner's message, activate the email, publish your campaign and enter it with an email address you can check.

Are comparisons case-sensitive?

Yes. "Yes" won't match "yes", and contains "Gold" won't match "GOLD". Make the text in your markup match the form answer or code exactly.

What shows if the entrant left a field empty?

Nothing. To show something instead, add a fallback, such as {{ entry.first_name | default: "there" }}, which shows "there" when the first name is blank.

Was this helpful?