Use liquid code in email messages for individual personalization

With the help of liquid code it is possible for you to include variable fields in e-mail messages. This way you can individually fill emails with the contact data available in doo. This article will describe how to do this and what customization options you have.

  1. Inserting liquid code through personalizations
  2. Write liquid code yourself

1. Insert liquid code through personalizations

To customize email messages to recipient lists and contact groups, you can use personalizations. To do this, click on the text module you inserted in your e-mail message, in which you want to insert placeholders. This will bring up a window with editing options. Click “Personalizations” here and select the appropriate field. Organization-, contact- and event-related placeholders are predefined.

Instead of simply inserting the default personalizations , you can further customize them.

For example, take the salutation placeholder: {{ contact.salutation }}. The placeholder can be further modified using filters. To do this, insert | and the desired filter inside the placeholder.

Ex: {{ contact.salutation | default: “Hello” }}. This example of using filters is helpful when the gender of the recipient is not known and where normally “Dear Sir/Madam” is given as default.

Some filters that are helpful for you can be found in the table below. More detailed information can be found here in the Liquid documentation.

{{ … | capitalize }} The input value is capitalized. title -> Title
{{ … | date: “%a, %b %d, %y” }} Dates are rendered in a different format. Here for example Fri, Jul 17, 15
{{ … | default: 2.99 }} Placeholders are assigned a default value if no data is present.
{{ … | downcase }} The input value is written in lowercase. Title -> title
{{ … | first }} Returns the first value of an *array
{{ … | join: ” and ” }} Joins values of an *array with For example here and
{{ … | last }} Returns the last value of an *array
{{ … | prepend: “List: ” }} Prepends a **string (Here List: ) to the **string obtained from the data.
{{ … | replace: “his”, “their” }} Replaces the First word (Here his) with the Second word (Here their) in a **String.

*Array = string of elements of a data type. The elements can be ordered by their position in the array (starting with 0).

**String = A string that results in words or sentences, for example, and is delimited by ” “.

2. Write liquid code yourself

With Liquid Code it is possible to define logical operations and a control flow. By using self-written Liquid Code in email messages, you can create standard emails that adapt their content to the type, timing, event status, size, etc. of the email. In addition, you can also customize the email to different groups of recipients so that customized information can be sent within a campaign.

To use Liquid Code properly and ensure that no incorrect content appears in email messages, you should only write code yourself if you have experience with other programming languages and concepts. In the approaches below, you will find examples of how some programming concepts are implemented in Liquid. For complete documentation on Liquid codes and uses, click here.

Defining variables:

{% assign organizer = "doo" %}


{% if event.price <= 20 %}
  This is a cheap event. 
{% endif %}
{% if contains "Extra" %}
  This is an additional event.
{% endif %}
{% if and > 10 %}
  Wow, {{ attendee }}, you have a long name!
{% else %}
{% endif %}

Split operator:

Splits a string into an *array at the defined char.

{% assign attendees = "John, Tim, Tina, Alex" | split: ", " %}

Address array indices:

{{ event.attendees[0] }}
 {{ event.attendees[1] }}
 {{ event.attendees[3] }}
Table of Contents

Didn’t find the answer to your question?

Our Support Team is happy to help