Skip to main content
All CollectionsEmailCampaign personalisation with Liquid
Loop, Decision, and Liquid markup building blocks
Loop, Decision, and Liquid markup building blocks

Create custom content using Liquid markup.

Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over 2 months ago

Liquid building blocks help you to create a tailored experience for each viewer. This means you can create an email campaign, page, or form, and the content is unique for each individual viewer. You can make personalised content by using the Loop, Decision, and Liquid markup building blocks.

adv-pers.png

What is Liquid?

Liquid is a markup language, which was developed for the ecommerce system Shopify.

Liquid allows you to create content that changes, depending on the current data, and acts as an extension to the CSS and HTML that emails and landing pages are built upon.


We use Liquid because many front end developers are used to working with it, or will find it easy to learn it. A fuller description of what is possible in Liquid can be found on Github.


Before you start

Things you need to know:

  • We support an extensive subset of the Liquid markup language. However, not all elements are supported.

  • You must have Advanced personalisation turned on for your account.

  • Liquid for SMS or MMS works slightly differently.
    Learn more in Personalisation for SMS and MMS.

  • There are reserved variable names.
    You can’t use the following variable names, as they're reserved for system-defined values:

    • account

    • contact

    • token

    • campaign

Custom code

The examples provided in this article are intended to help you understand the purpose and application of the Loop, Decision and Liquid markup building blocks, however using Liquid markup for personalisation is classed as custom code. Our Support team cannot troubleshoot your Liquid markup.


Loop block

The loop block repeatedly executes a block of code using certain types of insight data within your account.


In the following example we’ll create a loop that displays a customer’s top five latest orders:

Collection

  1. In EasyEditor, under Advanced personalisation, select and drag a Loop building block onto the canvas.

    loop-block.png

  2. Select the block’s Configuration icon.

    loop-configuration-button.png

  3. Expand the Select collection drop-down menu and choose an Insight data collection.

    loop-select-collection.png

  4. Expand the Order by drop-down menu and choose the field you want to order the collection by.

    loop-order-by.png

  5. This causes another drop-down menu to appear beneath, expand this drop-down menu and choose how the collection is ordered.

    Because we chose purchase_date, a date field, we can choose to order by Latest first or Earliest first.

    loop-order-by-2.png
  6. For Limit, increase or decrease the number of orders displayed in the loop by using the arrow buttons or entering a number.

    limit.PNG

  7. Expand the Columns drop-down menu and choose the number of columns you want the data to display across.

    loop-column.PNG

  8. Select APPLY.

This loop is now configured to show our latest orders. Next we need to set the order data we want displayed.

Order data

  1. In EasyEditor, under Advanced personalisation, select and drag a Loop building block inside your collection loop block.

    loop-inside-loop.png

  2. Select the block’s Configuration icon.

    loop-2-configuration-button.png

  3. Expand the Select collection drop-down menu and choose products, this is the Order property.

    loop-2-collection.png

  4. Expand the Order by drop-down menu and choose name.

    loop-2-order-by.png
  5. This causes another drop-down menu to appear beneath, expand this and choose how the collection is ordered.

    Because we chose name, an alphabetical field, we can choose to order by A-Z or Z-A.

    loop-2-order-by-2.PNG

  6. For Limit, increase or decrease the number of orders displayed in the loop by using the arrow buttons or entering a number.

  7. Select APPLY.

We now have two loops blocks that check the collection (Orders) and retrieves the data and orders it by purchase_date.

Orders-loop.png

The last thing we need to do is to add the action to the loops. To do this, we can add the name value for the product(s) inside the latest purchase for this collection.

Add personalisation values

  1. In EasyEditor, under Content, select and drag a Text block inside your loop block.

  2. Select the block, then select DATA FIELDS from the toolbar.

  3. Choose the data fields you want to display. For example, product_id, or name. The data fields you see here are relevant to the loop you have created.
    For better formatting, make sure to add additional data fields to a new line in the text block.

  4. Select SAVE.


Decision block

The Decision block works by setting decision criteria and returns one value for a TRUE result and another value for a FALSE result - this is commonly known as an IF statement.

In the following example we’ll create a loop that displays a customer’s orders if the price is less than 30:

Decision

  1. Create a loop block that’s configured to display Orders data.

    For more information see Collection.

  2. Under Advanced personalisation, select and drag a Decision building block inside the orders loop block.

    decision-block.png

  3. Select New content and add your when criteria. For this example it is: Orders.order_total < 30

    This shows orders where the total is less than 30.

    decision-criteria.PNG

  4. Select APPLY.

  5. Under Advanced personalisation, select and drag a Liquid markup building block inside decision block and enter the name value. For this example Orders is the collection name, and the name value is ID, so we enter: ####{{ Orders.ID }}.

    For more information see Name value.

decision-name-value.PNG

The decision block now checks for orders where the order_total value is less than 30 and displays them if TRUE, otherwise nothing is displayed.

You can set a rule for returning data when the decision is FALSE by placing a loop inside the Otherwise part of the decision block.

For more information see Loop block.


Liquid markup block

The Liquid markup block is a blank block which you can use for any custom liquid code.

To use the Liquid markup block:

  1. In EasyEditor, under Advanced personalisation, select and drag a Liquid markup building block onto your canvas.

    liquid-markup-block.png

  2. Select the block’s Configuration icon.

  3. Enter your custom liquid code.

  4. Select APPLY.

Did this answer your question?