Skip to content

Liquid in Triggered Emails

For each triggered email configuration you have to select a design. Each design has a type, and only designs of a type matching the triggered email type can be used. Each design has an associated base-design. The general idea of the base-design is that it can be reused across multiple designs, typically to have a common header and footer, so that the actual design only has to render the mail content.

Blocks

To implement the reuse of base-designs mentioned above, triggered emails has support for blocks in liquid. Blocks are a way for a template to give names to the content that it renderes. In the base design the content of these blocks can then be accessed by the names.

Example

In the example below a design provides two blocks named headline and content. In the base design these two blocks are added to the content in the required places.

Design

{% block headline %}
<h1>Be bold</h1>
{% endblock %}
{% block content %}
<p>Look alive people</p>
{% endblock %}

Base Design

<html>
    <body>
        <header>
            {{ blocks.headline }}
        </header>
        <section>
            {{ blocks.content }}
        </section>
    </body>
</html>

Liquid context

When implementing the design and the base design you have the following variables available in the liquid context. Some variables are only available in some types of triggered emails. Remember that the base design might be used across multiple types of triggered emails, so it should only use variables that are available on all types, or it should check if the variable exists before using it.

Available in all types

Variable Description
email Email address of the recipient of the email being rendered
unsubscribe_url The url that should be used to unsubscribe from further emails. This is typically used to render a unsubscribe link
subject The subject line configured for the triggered email. This is the value that will be used as subject when the email is sent. It might be useful as a headline inside the email as well

Available in abandoned cart emails

Variable Description
cart_url A back-to-cart url that was registered as part of the cart tracking. Is not required, so might be empty
cart_total The total value of the cart registered as part of the cart tracking
products A list of the products that were in the cart that was abandoned. See description of the product object in the introduction
firstProduct The first product from the products list
mostPopularProduct The most popular product from the products list
mostExpensiveProduct The most expensive product from the products list
relatedProducts A list of products found based on the recommendation algorithm that is configured on the triggered email. The context product provided to the algorithm is the cart products

Available in post conversion emails

Variable Description
receipt An object representing the conversion that was tracked and that this email is being triggered by. The object contains orderNumber, customerEmail, total and products. The products are the purchased products. See description of the product object in the introduction
products A list of products found based on the recommendation algorithm that is configured on the triggered email. The context product provided to the algorithm is the products from the receipt
firstProduct The first product from the products list
mostPopularProduct The most popular product from the products list
mostExpensiveProduct The most expensive product from the products list

Available in price-drop and back-in-stock emails

Variable Description
products A list of products that fell in price or are now back in stock, depending on the type of email. See description of the product object in the introduction
firstProduct The first product from the products list
mostPopularProduct The most popular product from the products list
mostExpensiveProduct The most expensive product from the products list

Available in base-designs

Variable Description
blocks A dictionary of blocks rendered by the design for the triggered email. See the description above