Liquid Templates: The Definitive Guide
You probably already know personalizing emails increases email engagement from open rates to customer conversions. Which is why you’ve probably merged a subscriber’s first name into your own emails before… but what happens when the punctuation and grammar is more complicated? Or when you want to talk to different segments of your list in the same email? That’s what we’ll cover in this guide!
Below you’ll find the ‘cheat codes’ for the most common liquid template examples. May this be your one-stop shop for remembering how to dynamically personalize your emails based on attributes like field values, events and tags (or the lack-thereof).
Let’s get started!
Table of Contents
What is Liquid?
Liquid is an open-source template language created by Shopify that Drip and other web applications use to display dynamic content in emails and set the value of fields and tags. Liquid code uses programming concepts such as output, logic and loops to replace shortcodes like {{ subscriber.first_name }} with a subscriber’s first name when an email is sent or an action is performed. Learn more about Liquid for Designers.
Liquid Objects
Objects tell Drip where data is located.
The Liquid shortcode for an object is {{ object }}. Double curly brace delimiters {{ }}, also called an output tag, output data in plain text which is useful for personalizing emails.
Below is a list of all the Drip object Liquid shortcodes.
- {{ broadcast }}
{{ campaign }}{{ event }}
{{ email }}
{{ item }}
{{ now }}
{{ product }}
{{ snippets }}
{{ subscriber }}
Example Liquid Objects
2024-06-23 12:32:48 -0700
{{ now }}
Liquid Attributes
Attributes are optional object variables like a subscriber’s first or last name.
The Liquid shortcode for an object and it’s attribute is {{ object.attribute }}.
Below is a list of all the default Drip liquid attribute shortcodes.
{{ broadcast.name }}
{{ email.subject}
{{ subscriber.created_at }}
{{ subscriber.email}
Example Liquid Attributes
2015-01-22 17:59:04 -0800
{{ subscriber.created_at }}
{{ subscriber.email }}
Liquid Filters
Filters begin with a pipe character | and are used to manipulate the output of an object or attribute.
The shortcode for a filter is {{ object | filter }} or {{ object.attribute | filter }}. Additional pipe characters can be used to perform multiple actions from left to right.
Below is a list of standard liquid filters and shortcode examples.
advance_date_to_next
append
at_midnight
capitalize
ceil
compact
date (see Liquid Dates below for formatting)
default
divided_by
downcase
escape_once
escape
first
floor
in_time_zone (see Liquid Time Zones for formatting)
join
last
lstrip
map
minus
modulo
newline_to_br
plus
prepend
remove_first
remove
replace_first
replace
reverse
round
rstrip
size
slice
sort
split
strip_html
strip_newlines
strip
times
truncate
truncatewords
uniq
upcase
url_encode
Example Liquid Filters
Some text
{{ ‘some text’ | capitalize }}
100
{{ 25 | times: 4 }}
Types of Berries:
{{ “Blueberries, Raspberries and Strawberries” | prepend: “Types of Berries: ” }}
Take your temperature
{{ “Take my temperature” | replace: “my”, “your” }}
211
{{ “2022-01-01” | days_since }}
73
{{ “2022-12-31” | weeks_until }}
Liquid Dates
Liquid dates convert a unix timestamp, which is the number of seconds that have elapsed since January 1, 1970 at UTC, to a more desired date format. UTC can be converted to another timezone by using the in_time_zone filter followed by a new Liquid time zone.
Below is a list all of Liquid Date formats and all Liquid time zones.
%a – Abbreviated weekday name (Sun)
%A – Full weekday name (Sunday)
%b – Abbreviated month name (Jan)
%B – Full month name (January)
%c – Preferred local date and time representation
%d – Day of the month (01 to 31)
%H – Hour of the day, 24-hour clock (0 to 23)
%I – Hour of the day, 12-hour clock (01 to 12)
%j – Day of the year (001 to 366)
%m – Month of the year (01 to 12)
%M – Minute of the hour (00 to 59)
%p – Meridian indicator (AM’ or PM’)
%s – Number of seconds since 1970-01-01 00:00:00 UTC
%S – Second of the minute (00 to 60)
%U – Week number of the current year, starting with the first Sunday as the first
day of the first week (00 to 53)
%W – Week number of the current year, starting with the first Monday as the first
day of the first week (00 to 53)
%w – Day of the week (Sunday is 0, 0 to 6)
%x – Preferred representation for the date alone, no time
%X – Preferred representation for the time alone, no date
%y – Year without a century (00 to 99)
%Y – Year with century
%Z – Time zone name
%% – Literal “%” characterNote: If you add a hyphen between the % and the letter, you can remove the leading zero i.e. %-I:%M
Example Liquid Date Shortcodes
Wednesday, July 27, 2022
{{ subscriber.created_at | date: “%A, %B %d, %Y” }}
Wednesday, July 27, 2022 at 12:38PM
{{ subscriber.created_at | date: “%A, %B %d, %Y at %-I:%M%p” }}
January 27, 2022 at 3:38 PM
{{ subscriber.created_at | in_time_zone: “America/New_York” | date: “%B %d, %Y at %I:%M%p” }}
2023-02-18 17:00:00 +0000
{{ now | date: “%Y” | plus: 1 }}-{{ subscriber.birthday | date: “%m” }}-{{subscriber.birthday | date: “%d” }} 17:00:00 +0000
Liquid Recap
To recap, Liquid objects are where data like someone’s first and last name gets stored, attributes are the actual first or last name, filters are formatting that can be performed on objects and attributes like capitalizing the first letter of a name and tags use logic to dynamically output any content in the same Liquid template.
Below we’ll share the most useful shortcodes you can add to your Drip email marketing and automations based on Drip fields, events and tags.
Drip Primary Fields
Primary fields, also called profile fields, are the default people fields attached to every Drip contact profile. Dynamically personalizing Drip emails based on the information stored in a primary profile field, like the ‘First Name’ field, is the most common type of liquid personalization.
Below is a list of Liquid shortcodes for all the Drip primary fields.
{{ subscriber.address1 }}
{{ subscriber.address2 }}
{{ subscriber.city }}
{{ subscriber.country }}
{{ subscriber.created_at }}
{{ subscriber.email }}
{{ subscriber.friendly_time_zone }}
{{ subscriber.eu_consent }}
{{ subscriber.lead_score }}
{{ subscriber.first_name }}
{{ subscriber.last_name }}
{{ subscriber.lead_score }}
{{ subscriber.phone }}
{{ subscriber.state }}
{{ subscriber.time_zone }}
{{ subscriber.zip }}
Example Primary Field Liquid Shortcodes
If the first name {{ subscriber.first_name }} field is empty, nothing will be outputted when an email with the shortcode is sent. To account for situations where you may not want a blank space to appear when the first name isn’t known (hint, every situation), we can use a default filter like in the first example below.
Hi Mat!
Hi {{ subscriber.first_name | default: “there” }}!
Hi, Mat!
Hi{% if subscriber.first_name %}, {{ subscriber.first_name }}{% endif %}!
Mat, how are you?
{% if subscriber.first_name%}{{ subscriber.first_name }}, how are you?{% endif %}{% if subscriber.first_name == blank%}How are you?{% endif %}
{{ subscriber.created_at | advance_date_to_next: “Friday” | date: “%A, %B %d, %Y” }}
Drip Custom Fields
Drip custom fields are Liquid attributes, also called field identifiers, that store contact data like the active or cancelled status of a membership in the {{ subscriber.membership_status }} custom field.
Dynamically inserting the contents of a custom field is a powerful way to personalize emails with Liquid.
Below are examples of the Liquid shortcodes that can be used to output the information in custom fields.
{{ subscriber.anything_you_like }}
Examples:
{{ subscriber.business_name }}
{{ subscriber.membership_level }}
{{ subscriber.stripe_cardholder_name }}
Example Custom Field Liquid Shortcodes
Congratulations on reaching Gold!
{% if subscriber.membership_level == “Gold” %} Congratulations on reaching Gold! {% endif %}
Borealis Computing Inc. Receipts:
{% if subscriber.business_name == “Borealis Computing Inc.” %}
Borealis Computing Receipts:
{% elsif subscriber.business_name == “Sound Camel” %}
Sound Camel Receipts:
{% else %}
Your Receipts:
{% endif %}
You're a Bronze member.
{% case subscriber.subscription_plan %}
{% when “Bronze” %}
You’re a Bronze member.
{% when “Silver” %}
You’re a Silver member.
{% when “Gold” %}
You’re a Gold member.
{% else %}
Become a member!
{% endcase %}
You have 3 item(s) in your cart
{% if subscriber.cart_item_count > 0 %}
<p>You have {{ subscriber.cart_item_count }} item(s) in your cart</p>
{% else %}
Check out our shop: https://soundcamel.com/shop
{% endif %}
Gold Member
{{ subscriber.subscription_plan | replace: “plan”, “member” }}
Example Above: ‘Gold plan’ turns into ‘Gold member’
GOLD
{{ subscriber.subscription_plan | split: ” ” | first | upcase }}
Example Above: ‘Gold Plan’ turns into ‘GOLD’
20% off until Thursday, January 8
20% off until {{ now | plus: 604800 | date: “%A, %B %e” }}
2
{{ subscriber.purchase_counter | plus: 1 | default: 0 }}
Thank you for your order!
{% assign order_total = purchase.value %}
{% assign discount_amount = 5 %}
{% assign discounted_total = order_total | minus: discounted_amount %}
Thanks for your order! Your subtotal was ${{ order_total }}, but your discount of ${{ discount_amount}} brings your total down to ${{ discounted_total }}.
Drip Predefined Events
Predefined events are sentence capitalized records that store the time and value of default Drip actions like ‘Opened an email’ or ‘Completed a workflow’. These records are listed in the ‘All Activity’ tab of a contact’s Drip profile and contain a plus symbol that can be expanded to view additional event data.
The Liquid shortcode for an event is {{ event.property_name }}. As an example, the liquid shortcode for the ‘Applied a tag’ subscriber event is {{ subscriber.applied_tag }}.
Events can trigger workflows and rules and event properties can be used to set primary or custom fields and apply tags using Liquid code.
When a customer makes a purchase, a ‘Paid an Order’ event will be recorded with event properties like the product name, price and currency.
Events allow for powerful filtering of specific parameters like anyone that placed an order on ‘August 1, 2022’. These filters can be used to create a saved segment or perform a bulk operation like applying a ‘customer’ tag.
Below is a list of all Drip predefined events that can be used in workflows and rules.
Applied a tag
Became a lead
Became a non-prospect
Became a potential lead
Bounced
Clicked a link
Clicked a trigger link
Completed an email series
Completed a workflow
Confirmed a form submission
Issued a spam complaint
Marked as undeliverable
Opened an email
Opted in to sms
Opted out of sms
Performed a custom event
Received an email
Removed a tag
Removed from an email series
Removed from a workflow
Replied to an email
Started a workflow
Submitted a form
Subscribed to an email series
Subscribed to email marketing
Subscriber created
Subscriber deleted
Text message clicked
Text message delivered
Unsubscribed from an email series
Unsubscribed from all mailings
Updated a custom field
Updated an alias
Updated email address
Updated lead score
Updated lifetime value
Updated time zone
Viewed a page
Viewed a product
Viewed eight pages in one visit
Visited a page
Visited twice in one week
Example Predefined Event Liquid Shortcodes
Invoice Email Template.
{{ event.product_name }}.
$49
{{ event.product_price | prepend: “$” }}
Drip Custom Events
Custom events are also time stamped, filterable records with an event name and event properties, called identifiers, that can be recalled. Custom events record any actions that are not predefined by Drip like when a customer upgrades their membership from ‘Silver’ to ‘Gold’ using a Zapier integration. Custom events can be manually applied by clicking the three vertically stacked dots in the upper right hand corner of a person’s profile, or in a bulk operation, workflow or rule.
Below is an example list of Drip custom events.
Clicked trigger link – dripemailtemplates.com
Example Custom Event Liquid Shortcodes
{{ event.abandoned_checkout_url }}
5 Hour Prepaid Retainer
Quantity: 1 – 5HR
Thank you for your purchase!
<p>{% for item in event.items %}<img src=”{{ item.image_url }}” /></p>
<p><b>{{ item.name }}</b></p>
<p>Quantity: {{ item.quantity }} – {{ item.product_id }}</p>
<p>{% endfor %}Thank you for your purchase!</p>
Drip Email Fields
Liquid email field shortcodes insert metadata related to the current email a person is interacting with, like the URL to view the email in a web browser.
Below is a list of Drip-specific email field Liquid shortcodes that can be added to your emails to give subscribers additional resources.
{{ broadcast.name }}
{{ campaign.name }}
{{ campaign.last_email_sent_at }}
{{ campaign.next_email_send_at }}
{{ confirmation_link }}
{{ confirmation_url }}
{{ edit_subscription_link }}
{{ edit_subscription_url }}
{{ email.subject }}
{{ from_email }}
{{ from_name }}
{{ html_postal_address }}
{{ inline_postal_address }}
{{ manage_subscriptions_link }}
{{ manage_subscriptions_url }}
{{ postal_address }}
{{ unsubscribe_link }}
{{ unsubscribe_url }}
{{ view_in_browser_link }}
{{ view_in_browser_url }}
Example Drip Email Field Liquid Shortcodes
Manage Your Email Subscription Here: {{ manage_subscriptions_url }}
Drip RSS-to-Email
RSS-to-email is a feature Drip support can activate in your account to automatically pull the content of your latest website posts into an email to be sent out to contacts. By default, Drip will notify you when a draft email with the latest posts is ready to be reviewed and sent. There is also a checkbox to skip this review process to automatically send your latest posts via a single campaign email.
After an RSS-to-email rule has been created under Workflows > RSS-to-email, the delivery preferences such as the allowed day of the week and email frequency like monthly, weekly, daily or hourly can be set. Drip RSS shortcodes are liquid shortcodes that can be added to emails to pull relevant website content into the body of your Drip emails.
Below is a list of all RSS-to-email Liquid shortcodes that can be added to emails to send your latest website content.
{{ feed.title }}
{{ feed.title_text }}
{{ feed.description }}
{{ feed.description_text }}
{{ feed.title_link }}
{{ feed.url }}
{{ latest_post.date }}
{{ latest_post.description }}
{{ latest_post.description_text }}
{{ latest_post.full_html }}
{{ latest_post.image }}
{{ latest_post.image_url }}
{{ latest_post.title }}
{{ latest_post.title_link }}
{{ latest_post.url }}
{{ post.author }}
{{ post.date }}
{{ post.description_text }}
{{ post.full_html }}
{{ post.image }}
{{ post.image_url }}
{{ post.title }}
{{ post.title_link }}
{{ post.url }}
Example RSS-to-Email Liquid Shortcodes
Hi there!
Here are the latest Drip Email Templates posts:
Liquid Templates: The Definitive Guide
This guide provides the ‘cheat codes’ for the most common Liquid template examples. May this be your one-stop shop for remembering how to dynamically personalize your emails based on attributes like field values, events and tags (or the lack-thereof).
The post Liquid Templates: The Definitive Guide appeared first on Drip Email Templates.
{% raw %}Hi {{ subscriber.first_name | strip | default: “there” }}!{% endraw %}
Here are the latest Drip Email Templates posts:
{% for post in posts %}
{{ post.title_link }}
{{ post.description }}
{% endfor %}
Wrapping up with Liquid
To recap, Drip fields, events and tags can trigger email marketing automations and output personalized messages in emails using Liquid code. RSS-to-email liquid shortcodes can pull your latest website content into Drip to be sent by email.
In the last two sections of this guide we’ll cover Liquid’s application in Drip email templates and the content snippets that can dynamically display content inside them.
Liquid Email Templates
Only two Liquid shortcodes are required to be added to Drip text email templates.
{{ email.html }} outputs the contents of the WYSIWYG email editor and {{ footer.html }} outputs the email marketing legal requirements that include an unsubscribe link and postal address.
Additional Liquid shortcodes from the Drip Email Fields section above can be added to offer an alternate option for contacts to opt-out such as by managing their subscription and opting out of individual campaigns instead using {{ manage_subscriptions_link }}.
{{email.html }}
{{ footer.html }}
Content Snippets
Content Snippets are reusable blocks of text or HTML that can be added to one or more emails where you would like to show the same content.
The Liquid shortcode for content snippets is {{ snippets.snippet_name }}.
Content snippets are a useful way to inject HTML into Drip’s visual email templates and can be applied to multiple emails, and in email templates.
As an example, the {{ snippets.email_signature }} content snippet is an easy way to add your email signature to the bottom of emails.
In another example, the {{ snippets.social }} content snippet could be added to the footer of an email template to achieve the exact look you’re after.
When snippets are modified the content displayed in all locations will also be updated, making them a convenient way to work with many emails in a series. Like website layout parts, but for emails!
Below is list of example content snippets and their Liquid shortcodes.
{{ snippets.anything_you_like }}
Examples:
{{ snippets.social }}
{{ snippets.email_signature }}
{{ snippets.ps }}
Example Content Snippets
{{ snippets.social }}
You are now a Liquid Templating master!
Congrats on your Liquid mastery! This definitive guide to Liquid templates covered every aspect of using Drip Liquid code to personalize your email marketing. Have any fantastic examples you’d like to share? Please leave a comment below!