Customer.io Liquid tag master list

Customer.io Liquid tag master list


This table should give you an idea of which Liquid tags and variables are available to you in Customer.io. Our version of Liquid is currently 2.5.3, so that dictates what we have available, as we're behind the original source code. Tag-specific syntax can be found here.

In the below table, we have standard liquid, liquid specific to Customer.io ("Customer.io Tag" and "Customer.io Filter"), array and string filters.

For array filters, assume you have the following array: acme.characters = "coyote", "bugs", "tweety".

Looking for something specific?

TypeThe LiquidWhat does it do?
Customer.io Tag{{content}}the tag used in layouts to indicate where the code added via the email editor will be included
Customer.io Tag{% unsubscribe_url %}This tag renders a unique unsubscribe link for that customer and email.
Customer.io Tag{% view_in_browser_url %}Our default link that generates a web version of your email, personalized for each recipient. Looks something like: http://e.customeriomail.com/deliveries/...
Customer.io Tag{{layout.id}}The numerical ID associated with the email layout you've used.
Customer.io Tag{{layout.name}The name you've assigned to the email layout you've used.
Customer.io Tag{{campaign.id}}Your campaign's numerical ID. This can be found in your campaign URL. For example, the campaign ID here is 2000: https://fly2.customer.io/env/12345/v2/campaigns/2000/overview
Customer.io Tag{{campaign.name}}This tag will output the name you've given your campaign in the Customer.io interface. For example: "Q2 Anvil Onboarding Campaign [Coyotes]"
Customer.io Tag{{campaign.type}}This returns whether or not your campaign is behavioral (segment triggered), transactional (event triggered), or a newsletter
Customer.io Tag{{message.id}}The numerical ID associated with a message action in the workflow— i.e. an SMS action might have a {{message.id}} of 200. Every SMS it generates has a different {{delivery_id}}.
Customer.io Tag{{message.name}}The name you give your message in the workflow. E.g. "Welcome to ACME!"
Customer.io Tag{{message.type}}This refers to a particular message's type. Possible values are: email_action, twilio_action, slack_action, webhook_action, urban_airship_action, attribute_update_action
Customer.io Tag{{message.subject}}If your message has a subject (or if it's different to the message name) this tag will echo it.
Customer.io Tag{{event_name}}The name of the event that powers your event triggered campaign.
Customer.io Tag{{event_timestamp}The UNIX timestamp for when a particular event was performed. Keep in mind that this is different from 'now'!
Customer.io TagnowThe current time in UTC. Needs to be formatted with date. e.g. {{ 'now' | date: "%H:%M %p %B %d, %Y" }} returns the current time in this format: 06:54 AM August 31, 2017
Customer.io Tag{{delivery_id}}A URL-compatible base64 string that identifies a specific message created for an end-user. This is set to unsent in test send and composer previews, and generated when the message is drafted or sent.
Customer.io FilterroundRounds a number to the nearest integer, or to a decimal you specify. e.g.{{ 4.637 | round }} will output 5, while {{ 4.637 | round: 2 }} will output 4.64
Customer.io Filternumber_with_delimiterAdds a delimeter to a number. e.g. {{ 10000 | number_with_delimiter }} outputs 10,000. We don't have the option to specify the delimiter here so the default , delimiter will be used.
Customer.io Filternumber_to_currencyFormats a number into a currency. e.g. {{ 8 | number_to_currency }} outputs $8.00. We don't have the locale: option here.
Customer.io Filterrounded_currencyRounds a number into the nearest whole integer, and formats it to a currency. e.g.{{ 8.01234 | rounded_currency }} outputs $8. We don't have the locale: option here.
Customer.io FilterurlencodeEscapes/encodes any URL-unsafe characters in a string. e.g. {{ "Hello, world!" | urlencode }} outputs Hello,%20world! Note, for email addresses, you will want to use the 'escape' filter below as some characters that are allowed in email addresses (i.e., + and @) are not considered URL-unsafe characters and they will not be replaced by this filter.
Customer.io FilterhtmlencodeEscapes/encodes reserved HTML characters in a string. e.g. {{ <p>Hello, world!</p>" | urlencode }} outputs <p>Hello,%20world!</p>
Customer.io FilterescapeEscapes/encodes all special characters e.g. {{ "Hello, world!" | urlencode }} outputs Hello%2C%20world%21.
Customer.io Filterbase64Base64-encodes a string. {{ 'Hello, world!' | base64 }} returns SGVsbG8sIHdvcmxkIQ==.
Customer.io Filteradd_yearAdds a year, or multiple years, to a given timestamp e.g. {{ 1477430251 | add_year }} outputs 1508966251. You can also use {{ 1477430251 | add_year: 4 }}
Customer.io Filteradd_monthAdds a month, or multiple months, to a given timestamp e.g. {{ 1477430251 | add_month }} outputs 1480108651. You can also use {{ 1477430251 | add_month: 2 }}
Customer.io Filteradd_dayAdds a day, or multiple days, to a given timestamp e.g. {{ 1477430251 | add_day }} outputs 1477516651. You can also use {{ 1477430251 | add_day: 7 }}
Customer.io FiltertimezoneConverts a timestamp to a timezone you specify. e.g. {{ 1483272000 | timezone: 'US/Pacific' | date: "%H:%M, %a, %b %d, %Y"}} outputs 04:00, Sun, Jan 01, 2017. You can also use 'now' instead of a timestamp. Timezone inputs can be: timezone: '-3' (specify your number) or UTC
Customer.io Filterto_jsonOuputs the json representation of the input e.g. {{ customer | to_json }} will send all your customer data into a JSON variable.
Customer.io FilterrandomGenerates a random number between 0 and NUM. e.g. {% random 10 %} will generate a random number between 0 and 10.
Standard LiquiddateReformat a date. e.g. {{ 1483272000 | date: "%H:%M, %a, %b %d, %Y"}} will output 12:00, Sun, Jan 01, 2017. Here's a syntax reference
Standard LiquidcapitalizeCapitalize the first character in a string. e.g. {{ "hello, world" | capitalize }} will output Hello, world
Standard LiquiddowncaseConverts a string to lower case. e.g. {{ "ACME" | downcase }} will output acme
Standard LiquidupcaseConverts a string to upper case. e.g. {{ "acme" | upcase }} will output ACME
Standard LiquidtitlecaseConverts a string to title case. e.g. {{ "rocket roller skates" | titlecase }} will output Rocket Roller Skates
Array FilterfirstReturns the first element of the array. e.g. {{ acme.characters | first }} will output coyote
Array FilterlastReturns the last element of the array. e.g. {{ acme.characters | last }} will output tweety
Array FilterjoinJoins the elements of an array with the character passed as the parameter. e.g. {{ acme.characters | join: ', ' }} will output coyote, bugs, tweety
Array FiltersortSorts the elements of an array by a given attribute of an element in that array. Usually used with a 'for' loop. See this example, and remember that the order of the sorted array is case-sensitive!
Array FiltermapCreates an array of values by extracting the values of a named property from another object. If you have the object: "[{""name"":""coyote""},{""name"":""bugs""},{""name"":""tweety""}]", you can use map like this, to create a new array of the character names:


assign names = customer.characters | map: 'name' %}

Then, to output them, you can use a 'for' loop. See syntax.

Array FiltersizeReturns the size of a string (in characters) or an array (number of elements). e.g. {{ "That's all, folks!" | size }} will output 18
String FilterescapeEscaping (or encoding) a string removes special characters. e.g. {{ "Hey there, world!" | escape }} will output Hey%20there%2C%20world%21
String Filterescape_onceEscapes or encodes a string, but doesn't include already-escaped characters. e.g. {{ "1 < 2 & 3" | escape_once }} will output 1 < 2 & 3
String Filterstrip_htmlRemoves HTML characters from a string. e.g. {{ "Eh, what's <i>up</i>, <b>Doc<b>?" | strip_html }} will output Eh, what's up, Doc?
String Filterstrip_newlinesRemoves line breaks (\n) from a string. e.g. {{ product.description | strip_newlines }} will remove all line breaks from your product description, if there are any.
String Filternewline_to_brReplaces newline with an HTML line break. See this example for output.
String FilterreplaceReplace each occurrence of A with B. e.g. {{ "Coyotes never catch roadrunners!" | replace: "never", "always" }} will output Coyotes always catch roadrunners!
String Filterreplace_firstSame as above, but only replaces the first instance of A. e.g. {{ "roller rocket roller skates" | replace_first: "roller", "awesome" }} will output awesome rocket roller skates
String FilterremoveRemoves a specified item from a string. e.g. {{ "And that's all, folks!" | remove: ", folks" }} will output And that's all!
String Filterremove_firstRemoves the first occurrence of a specified item from a strong. e.g. {{ "folks that's all folks!" | remove_first: "folks" }} will output that's all folks!
String FiltertruncateShortens a string down to the given number of characters, adding an ellipsis. e.g. {{ "I knew I shoulda taken that left turn at Albuquerque." | truncate: 20 }} will output I knew I shoulda ...
String FiltertruncatewordsShortens a string down to the number of words passed, instead of characters, and adds an ellipsis. e.g. {{ "I knew I shoulda taken that left turn at Albuquerque." | truncatewords: 8 }} will output I knew I shoulda taken that left turn...
String FilterprependAdds a specified string to the beginning of another string. e.g. {{ "Sufferin' succotash!" | prepend: "Sylvester: " }} will output Sylvester: Sufferin' succotash!
String FilterappendPuts together two strings. e.g. {{ "What's all the hubbub, " | append: "bub?" }} will output What's all the hubbub, bub?
String FiltersplitDivides an input string into an array using a separator you define. Often used with a for loop. See this Beatles example.
Math FilterminusSubtracts a number from another number. e.g. {{ 10 | minus: 1 }} will output 9
Math FilterplusAdds a number to another. e.g. {{ 10 | plus: 1 }} will output 11
Math FiltertimesMultiplies a number by another. e.g. {{ 5 | times: 2 }} will output 10
Math Filterdivided_byDivides a number by a number you specify. e.g. {{ 10 | divided_by: 4 }} will output 2, while {{ 10 | divided_by: 4.0 }} will return 2.5
Math FiltermoduloReturns the remainder of division. e.g. {{ 3 | modulo: 2 }} will output 1
Math FiltercurrencyConverts an integer to currency. e.g. {{ 10 | currency }} will output $10.00
Standard TagcommentDoesn't show the content inside of it. e.g. {% comment %} Don't display me! {% endcomment %}
Standard TagassignAssigns a specific value to a variable. e.g. {% assign favorite_food = 'apples' %} creates {{ favorite_food }}
Standard TagcaptureCaptures a string and assigns it to a variable. e.g. {% capture about_me %}I am 28 and my favorite food is pasta.{% endcapture %} creates {{ about_me }}
Standard TagcaseCreates a switch statement that depends on a variable's specific value. For example, you might use this to display different text depending on if a customer lives in a specific country.
Standard TagcycleLoops through strings and outputs them in the order they were passed. It needs to be used in a 'for' loop! So if you have the array ["coyote","bugs","tweety"] held in a customer attribute, you can do this: {% for character in customer.characters %} <li class=""{% cycle 'odd', 'even' %}>{{ character }}</li>{% endfor %}

This will output:
  • coyote
  • bugs
  • tweety

  • With alternating 'odd' and 'even' CSS classes, like this: <li class="odd">coyote</li><li class="even">bugs</li><li class="odd">tweety</li>

    Standard TagforRepeatedly executes a block of code. See syntax here.
    Standard TagifExecutes a block of code if a certain condition is met. See syntax here.
    Standard TagunlessLike if, but this code is executed if a certain condition is not met. See syntax here.
    Standard TagrawTemporarily disable Liquid processing. See syntax here.

    Need help?

    For all of the above tags, we have our own syntax guide which we've linked above. If you need specific guidance wth how to use a particular tag with Customer.io, let us know!

    Was this article helpful?