Skip to content

Advanced Mail Merging

Emails sent out from Insights workflows support the Liquid template markup. This markup allows "if" statements and "for each" iteration through arrays.

Markup Syntax

Use two curly brackets and then the slug name for outputting the value of a variable e.g. {{}} to output the name of the event that triggered the workflow. 

Note: Our standard mail merge uses triple curly brackets. For example {{{}}} would merge in the name of the event that triggered the workflow. Our advanced Liquid markup uses double curly brackets, for example {{}}.


The variable slugs are the same as those of our standard mail merge, except Liquid requires two curly brackets as opposed to triple curly brackets. {{ }} is the name of the event. {{ event.attributes.url }} represents the value 'url' attribute of the event.

Common Helpers

  • capitalize
  • capitalize_all
  • currency
See usage in examples below.


Output event name

{{ }}

Output name or "there" and capitalize the first letter

{{ first_name | default: 'There' | capitalize }} => Bob (if name is bob)

{{ first_name | default: 'There' | capitalize }} => There  (if name is blank)

Capitalize the first letter of multiple words

e.g. event.attributes.product_name => Amazing purple widget

{{ event.attributes.product_name | capitalize_all }} => Amazing Purple Widget

Output the event attribute 'url'

{{ event.attributes.url }}

If/Else Blocks

{% if event.attributes.color == 'blue' %}
  Hello BLUE
{% elsif event.attributes.color == 'green' %}
{% else %}
  You don't like my fav colors? You like: {{ event.attributes.color }} ?
{% endif %}

For Loops

To look through the event attribute array "items":
{% for product in event.attributes.items %}
      <span>{{ }} {{ product.price }}</span>
{% endfor %}


We have a special filter to help properly format currency. 

By default, the format is US format: 
e.g. event.attributes.Price => 123.4
{{ event.attributes.Price | currency }} => $123.40

To specify the currency format for a particular country (use two letter country codes):
e.g. for France, you can use the country code "fr" (should be lower case)

{{ 12345.67 | currency: locale: :fr }} => 12 345,67 €

To change or exclude the currency type, simply add on the "unit" option:
e.g. event.attributes.Price => 123.4
{{ event.attributes.Price | currency: unit: 'R$' }} => R$123.40

Here is a full list of options that can be passed on:
  • :locale - Sets the locale to be used for formatting (defaults to current locale).
  • :precision - Sets the level of precision (defaults to 2).
  • :unit - Sets the denomination of the currency (defaults to “$”).
  • :separator - Sets the separator between the units (defaults to “.”).
  • :delimiter - Sets the thousands delimiter (defaults to “,”).
  • :format - Sets the format for non-negative numbers (defaults to “%u%n”). Fields are %u for the currency, and %n for the number.
  • :negative_format - Sets the format for negative numbers (defaults to prepending an hyphen to the formatted number given by :format). Accepts the same fields than :format, except %n is here the absolute value of the number.
The following example is setting the currency sign to "#", the separator to "," (instead of a "."), and the thousand delimiter to a "." (instead of a ","), and the format of the number is changed to display the number first then the currency sign:

e.g. event.attributes.Price => 12367.4567
{{ event.attributes.Price | currency: unit: '#', separator: ',', delimiter: '.', format: '%n %u', precision: 2 }} => 12.367,46 #

Fetching JSON

We offer the ability to fetch data from a third party service with the option to GET information. The service needs to return a JSON.

The format is: 
{% assign variable_name = 'http(s)://' | fetch_json %}
You can also merge in a value to the url of the service
{% assign variable_name = 'http(s)://url-of-service/api?email={{email_address}}' | fetch_json %}

{% assign items = '' | fetch_json %}

{{items[0].name}}   => the value of the name attribute in the first array ... e.g. "id labore ex et quam laborum" 

Other examples

Liquid for Designers for a primer on advanced filters and tags

Feedback and Knowledge Base