Scripting content with advanced personalisation

Please note

We support an extensive subset of the full Liquid language. However, you may occasionally find that some elements aren't supported.

Summary

Advanced personalisation (if it is enabled on your account) provides a rich way to create highly targeted and relevant content through landing pages and emails. In extension to other means of personalisation, advanced personalisation can be used to:

  • Put insight data into an email campaign
  • Put insight data into a landing page
  • Loop through collections of data to repeat blocks of HTML to each relevant piece of content
  • Manipulate the way text, dates, currency and numbers are displayed
  • Show content depending on address book membership
  • Abort a send to a contact if the content would not be relevant
  • Use complex logic to determine what content should be displayed to each contact

While simple interface tools exist for creating advanced personalisation; some of the most powerful personalisation can be done by using the markup language 'Liquid'.

Even if you're not going to write the Liquid markup yourself, it's useful to have an overview of what it is and what it can achieve.

What is 'Liquid'?

Liquid is a markup language developed for the eCommerce system Shopify. It allows template designers freedom to create content that adapts according to the data provided, and acts as an extension to the CSS and HTML that emails and landing pages are built upon.

We have opted to use Liquid as it is a commonly used markup language that many front end developers will be used to working with, or will find it easy to adapt to. A fuller description of what is possible in Liquid can be found on Github.

Below we describe how to construct advanced personalisation.

The basic elements of advanced personalisation

Advanced personalisation depends on:

  • Data to determine why one contact should see different content to another.
  • Logic to determine how that data is used to show different content to different contacts
  • Content to display to those contacts (or not) using HTML, CSS and filters on the data provided

These are achieved through OutputsTags and Filters (described below).

Outputting data into content

Outputs can be used to take data and create content.

For example:

Hello {{ contact.data.firstname }},

This will output 'Hello' followed by the first name stored for a particular contact.

Those of you used to our standard personalisation will note that this is exactly equivalent to:

Hello @FIRSTNAME@,

In this case we outputted a piece of contact data; we can also output account specific data. For example:

Hello {{ contact.data.firstname }}, the current time is {{ account.datetime }}.

This will show a message to the named contact containing the current date and time.

For a complete list of all the data that can be outputted check our documentation on outputs and data objects.

For outputting insight data; you'll need to know about logic tags (below) and see our guide to outputting insight data.

Filtered outputs

You can use filters to change the way outputs are displayed; for example:

Hello {{ contact.data.firstname }}, the current date is {{ account.datetime}}.

Might be outputted as:

Hello ben, the current date is 05/08/2015 07:30:31.

But it can be changed with filters as follows:

Hello {{ contact.data.firstname | capitalize }}, the current date is {{ account.datetime | date: "%e %B %Y" }}.

To show:

Hello Ben, the current date is 05 August 2015.

Note that the first element in the output (surrounded by {{}} brackets ) is always what gets outputted, and the other bits (separated by | pipes) are filters.

An output can have multiple filters.

For example:

{{ account.datetime | date: "%e %B %Y" | upcase }}

Will output the date in the format containing the day (dd), month and year, then uppercase all letters inside it:

05 AUGUST 2015

Various filters are available for manipulating text, numbers, dates and arrays. See our list of available filters.

Logic tags

Tags are used when building logic to tell your content what to do, for example:

{% if contact.data.firstname == 'ben' %}
Hey Ben!
{% else %}
Hello there!
{% endif %}

In the above example, this will show different content depending on whether or not the contact's first name is 'ben'. This functions pretty much as our regular dynamic content.

A more interesting example is using "for" loops, for example:

{% for book in contact.addressbooks %}
{{ book.name }} <br/>
{% endfor %}

This will get the list of address books that a contact is in, and for each address book show the name of the book followed by a line break.

For a full list of supported logic tags, see our documentation using logic tags in campaigns and landing pages.

Even with these basic rules advanced personalisation allows for some truly tailored content but the power really comes when you combine all the options available.

Spacing: a cautionary note

Liquid markup can be very sensitive to spacing. For example:

{% if 1 == 1 %}

Will evaluate to 'true'.

{% if 1==1 %}

Will fail.

Separating each operator there should be a single space.

Have more questions? Submit a request

Comments

Powered by Zendesk