Customer.io Liquid tag 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?
Type | The Liquid | What 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 or newsletter 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.journey_id}} | The ID for the path a person went through in a Campaign or API Triggered Broadcast workflow. This can be used to trace message metrics back to a person's unique workflow journey using the journey.id value sent in our Reporting Webhooks. |
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 Tag | now | The 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.To use any of the add or subtract filters you will need to convert 'now' into something usable first. E.g., {{ 'now' | date: '%s' | plus: 0 | add_day: 1 | date: '%Y-%m-%d %H:%M'}} |
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 Filter | floor | Rounds a number down to the nearest integer. e.g.{{ 4.637 | floor }} will output 4 |
Customer.io Filter | ceil | Rounds a number up to the nearest integer. e.g.{{ 4.637 | ceil }} will output 5 |
Customer.io Filter | abs | Returns the absolute value of a number. e.g.{{ 4.637 | abs }} will output 4.637 |
Customer.io Filter | round | Rounds a number up or down 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 Filter | rounded_currency | Rounds 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 Filter | format_number | Format a number with a delimiter, e.g. {{ 10000 | format_number }} outputs 10,000. This filter also takes an optional localization parameter to format a number for a specific locale e.g. {{ 123456.78 | format_number: "fr" }} outputs 123 456,78 . Note: This replaces the former number_with_delimeter filter. |
String Filter | escape | Escaping (or encoding) a string removes special characters. e.g. {{ "Hey there, world!" | escape }} will output Hey there%2C world%21 and {{ "win+help@customer.io" | escape }} will output win%2Bhelp%40customer.io |
String Filter | escape_once | Escapes or encodes a string, but doesn't include already-escaped characters. e.g. {{ "1 < 2 & 3" | escape_once }} will output 1 < 2 & 3 |
Customer.io Filter | htmlencode | Escapes HTML characters into HTML entities. |
Customer.io Filter | urlencode | Escapes/encodes any URL-unsafe characters in a string. e.g. {{ "Hello, world!" | urlencode }} outputs Hello, world! 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 Filter | base64 | Base64-encodes a string. {{ 'Hello, world!' | base64 }} returns SGVsbG8sIHdvcmxkIQ== . |
Customer.io Filter | add_year | Adds 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 Filter | add_month | Adds 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 Filter | add_day | Adds 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 Filter | subtract_year | Subtracts a year, or multiple years, to a given timestamp e.g. {{ 1477430251 | subtract_year }} outputs 1445807851 . You can also use {{ 1477430251 | subtract_year: 4 }} |
Customer.io Filter | subtract_month | Subtracts a month, or multiple months, to a given timestamp e.g. {{ 1477430251 | subtract_month }} outputs 1474838251 . You can also use {{ 1477430251 | subtract_month: 2 }} |
Customer.io Filter | subtract_day | Subtracts a day, or multiple days, to a given timestamp e.g. {{ 1477430251 | subtract_day }} outputs 1477343851 . You can also use {{ 1477430251 | subtract_day: 7 }} |
Customer.io Filter | timezone | Converts 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 Filter | to_json | Ouputs the json representation of the input e.g. {{ customer | to_json }} will send all your customer data into a JSON variable. |
Customer.io Filter | random | Generates a random number between 0 and NUM. e.g. {% random 10 %} will generate a random number between 0 and 10. |
Standard Liquid | date | Reformat 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 Liquid | capitalize | Capitalize the first character in a string. e.g. {{ "hello, world" | capitalize }} will output Hello, world |
Standard Liquid | downcase | Converts a string to lower case. e.g. {{ "ACME" | downcase }} will output acme |
Standard Liquid | upcase | Converts a string to upper case. e.g. {{ "acme" | upcase }} will output ACME |
Standard Liquid | titlecase | Converts a string to title case. e.g. {{ "rocket roller skates" | titlecase }} will output Rocket Roller Skates |
Array Filter | first | Returns the first element of the array. e.g. {{ acme.characters | first }} will output coyote |
Array Filter | last | Returns the last element of the array. e.g. {{ acme.characters | last }} will output tweety |
Array Filter | join | Joins the elements of an array with the character passed as the parameter. e.g. {{ acme.characters | join: ', ' }} will output coyote, bugs, tweety |
Array Filter | sort | Sorts 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 Filter | map | Creates 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:
Then, to output them, you can use a ‘for’ loop. See syntax. |
Array Filter | size | Returns the size of a string (in characters) or an array (number of elements). e.g. {{ "That's all, folks!" | size }} will output 18 |
Array Filter | remove |
Removes a specific element from the array. The array can contain objects of any type. For example:{% assign pl = collection.products | remove: collection.products[0] %}{{ collection.products.size }}{{ pl.size }} outputs: 2 1 |
Array Filter | where |
Creates an array including only the objects with a given property value, or any "truthy" value by default. When using where , you provide two items separated by a comma: the key you want to match on and the value you want to match. For example, this:
outputs this:
|
Array Filter | where_not |
Creates an array of items that do not match a given property value, or any "falsy" value by default. When using where_not , you provide two items separated by a comma: the key you want to match on and the value you want to match. For example, this:
outputs this:
|
Array Filter | concat |
Concatenates arrays, joining them end to end. The resulting array contains all of the elements of both original arrays. `concat` does not remove duplicate entries unless you also use the `uniq` filter. For example:
outputs:
|
Array Filter | sort_natural |
Sorts items in an array in case-insensitive order. For example: {{ "mick, keith, Charlie, Ronnie" | sort_natural }} outputs Charlie, keith, mick, Ronnie |
Array Filter | compact |
Removes nil (empty) values from an array.
e.g. {{ "mick, keith, nil, Charlie" | compact }}
outputs mick, keith, Charlie |
String Filter | slice | Returns the character located at the index specified in the first argument. {{ "Customer.io" | slice: 0 }} will output C {{ "Customer.io" | slice: 3 }} will output t For more than one character, include a second argument to specify how many characters to return. e.g.: {{ "Customer.io" | slice: 3, 3 }} will output tom When the first argument is a negative number, the index is counted from the end of the string. e.g.: {{ "Customer.io" | slice: '-4', 3 }} will output r.i
|
String Filter | strip_html | Removes 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 Filter | pluralize |
Outputs the singular or plural version of a string based on the value of a number. The first parameter is the singular string and the second parameter is the plural string. For example: {{ event.item_count | pluralize: 'item', 'items' }} outputs
3 items |
Array Filter | remove |
Removes a specific element from the array. The array can contain objects of any type. For example:{% assign pl = collection.products | remove: collection.products[0] %}{{ collection.products.size }}{{ pl.size }} outputs: 2 1 |
String Filter | url_encode |
Converts URL-unsafe characters in a string into percent-encoded characters. This filter also converts spaces to + characters.{{ "cio@example.com" | url_encode }} outputs
cio%40example.com |
String Filter | url_decode |
Decodes a string that has been encoded as a URL or has been modified by url_encode . For example:{{ "%27Customer.io+is+great%27" | url_decode }} outputs
'Customer.io is great' |
String Filter | strip |
Strips tabs, spaces, and newlines (all whitespace) from the left and right side of a string.
filter. For example:{{ " Customer.io " | strip }} outputs
Customer.io |
String Filter | lstrip |
Strips tabs, spaces, and newlines (all whitespace) from the left side of a string.
filter. For example:{{ " Customer.io " | lstrip }} outputs
Customer.io |
String Filter | rstrip |
Strips tabs, spaces, and newlines (all whitespace) from the right side of a string.
filter. For example:{{ " Customer.io " | strip }} outputs
Customer.io |
String Filter | strip_newlines | Removes 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 Filter | newline_to_br | Replaces newline with an HTML line break. See this example for output. |
String Filter | replace | Replace each occurrence of A with B. e.g. {{ "Coyotes never catch roadrunners!" | replace: "never", "always" }} will output Coyotes always catch roadrunners! |
String Filter | replace_first | Same 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 Filter | remove | Removes a specified item from a string. e.g. {{ "And that's all, folks!" | remove: ", folks" }} will output And that's all! |
String Filter | remove_first | Removes 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 Filter | truncate | Shortens 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 Filter | truncatewords | Shortens 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 Filter | prepend | Adds a specified string to the beginning of another string. e.g. {{ "Sufferin' succotash!" | prepend: "Sylvester: " }} will output Sylvester: Sufferin' succotash! |
String Filter | append | Puts together two strings. e.g. {{ "What's all the hubbub, " | append: "bub?" }} will output What's all the hubbub, bub? |
String Filter | split | Divides an input string into an array using a separator you define. Often used with a for loop. See this Beatles example. |
String Filter | uniq | Removes duplicate elements in an array. Using {{ my_array | uniq | join: ", " }} on my_array containing "lions, tigers, bears, bears, lions" will output lions, tigers, bears |
String Filter | md5 | Converts a string into an md5 hash.{{ "Customer.io" | md5 }} will output d52b6a207bf5255c05b1d0056230617e |
String Filter | sha1 | Converts a string into a sha1 hash.{{ "Customer.io" | sha1 }} will output c197ff0ae0a41983362f35ca972c544061c54d4c |
String Filter | sha256 | Converts a string into a sha256 hash.{{ "Customer.io" | sha256 }} outputs 6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57 |
String Filter | hmac_sha1 | Converts a string into an hmac_sha1 hash.{{ "Customer.io" | hmac_sha1: "some_key" }} will output 2bdf556c9a75766f258d1e2824f6d0e31d1beedc |
String Filter | hmac_sha256 | Converts a string into an hmac_sha256 hash.{{ "Customer.io" | hmac_sha256: "some_key" }} will output 6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57 |
String Filter | hex_base64 | Returns a base64 encoding of a hex digest such as ones returned by the hmac_sha256 filter.{{ "Customer.io" | hmac_sha256: "some_key" | hex_base64 }} will output bd23cyOCFrzicxM7w/ahKoJPQd0YTQlFLwXHZZ2ufVc= |
Math Filter | minus | Subtracts a number from another number. e.g. {{ 10 | minus: 1 }} will output 9 |
Math Filter | plus | Adds a number to another. e.g. {{ 10 | plus: 1 }} will output 11 |
Math Filter | times | Multiplies a number by another. e.g. {{ 5 | times: 2 }} will output 10 |
Math Filter | divided_by | Divides 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 Filter | modulo | Returns the remainder of division. e.g. {{ 3 | modulo: 2 }} will output 1 |
Math Filter | currency | Converts an integer to currency. e.g. {{ 10 | currency }} outputs $10.00 . This filter takes an optional localization parameter to format currency for specific locale, e.g. {{ 123456.78 | currency: "fr" }} outputs 123 456,78€ . |
Math Filter | at_least |
Limits a number to a minimum value. For example {{ 41 | at_least: 42 }} outputs 42 |
Math Filter | at_most |
Limits a number to a maximum value. For example {{ 100 | at_most: 99 }} outputs 99 |
Standard Tag | comment | Doesn't show the content inside of it. e.g. {% comment %} Don't display me! {% endcomment %} |
Standard Tag | assign | Assigns a specific value to a variable. e.g. {% assign favorite_food = 'apples' %} creates {{ favorite_food }} |
Standard Tag | capture | Captures 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 Tag | case | Creates 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 Tag | cycle |
Loops 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:
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 Tag | for | Repeatedly executes a block of code. See syntax here. |
Standard Tag | if | Executes a block of code if a certain condition is met. See syntax here. |
Standard Tag | unless | Like if, but this code is executed if a certain condition is not met. See syntax here. |
Standard Tag | raw | Temporarily disable Liquid processing. See syntax here. |
Localization Parameters
Some Liquid tags, like the currency
and format_number
tags, take an optional localization parameter, formatting the output for a specific locale. These tags use the format {{ 10 | currency: "en-us" }}
, which would output $10.00
.
We support the following localization values.
af, ar, az, be, bg, bn, bs, ca, cs, cy, da, de, de-AT, de-CH, de-DE, el, el-CY, en, en-AU, en-CA, en-GB, en-IE, en-IN, en-NZ, en-US, en-ZA, en-CY, en-TT, eo, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, gl, he, hi, hi-IN, hr, hu, id, is, it, it-CH, ja, ka, km, kn, ko, lb, lo, lt, lv, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or, pa, pl, pt, pt-BR, rm, ro, ru, sk, sl, sq, sr, st, sw, ta, te, th, tl, tr, tt, ug, ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE
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!