Liquid templates
Liquid templates significantly broaden Pushwoosh’s personalization capabilities by implementing sophisticated logic in addition to regular Dynamic Content usage.
Message personalization in Pushwoosh is based on Tags (user data). Pushwoosh offers a variety of default Tags and custom Tags. Using them, you can specify user’s first name, city, purchase history, etc. to send a more personalized message, for example: Hi {First_name}, thanks for ordering {item}.
Liquid templates add more logic to dynamic content. For instance, if a user’s subscription tag contains “free,” you can send them a message: “Grab your 10% discount.”
Modifying the message content according to users’ IDs, behaviors, and preferences is the most efficient way to increase relevance and get more impressive results from your marketing campaigns.
Syntax
Content templates based on Liquid by Shopify use a combination of tags, objects, and filters to load dynamic content. Content templates allow to access certain variables from within a template and output their data without having to know anything about the data itself.
Objects
objects
define the content that will be displayed to a user. objects
should be enclosed in double curly braces: {{ }}
For example, when personalizing a message, send {{Name}}
in its body to add the users’ names to the message’s content. The user’s name (Name tag value) will replace the Liquid object in a message the user will see.
Hi Anna! We’re glad you’re back!
Tags
tags
create the logic and control flow for templates. The curly brace percentage delimiters {%
and %}
and the text that they surround do not produce any visible output when the template is rendered. This lets you assign variables and create conditions or loops without showing any of the Liquid logic to a user.
For example, using the if
tag, you can vary the message’s language based on what language is set on user’s device:
Input:
Output (fr): Salut!
Output (es): Hello!
Tags operators
Operator | Description |
---|---|
== | equals |
!= | does not equal |
> | greater than |
< | less than |
>= | greater than or equal to |
<= | less than or equal to |
or | logical or |
and | logical and |
contains | checks for the presence of a substring inside a string or array of strings |
Filters
filters
modify the output of a Liquid object or variable. They are used within double curly braces {{ }}
and variable assignment, and are separated by a pipe character |
. Multiple filters can be used on one output, and are applied from left to right.
Input | Output |
---|---|
{{ Name | capitalize | prepend:"Hello " }} | Hello Anna |
Connected content
Connected content is a feature in Liquid templates that allows you to dynamically retrieve and use data from an external source, such as a web service, directly within your email or push notification templates. This feature enables real-time personalization by fetching JSON data from a specified URL and saving it to a variable that can be utilized in your content.
Example usage
Consider a scenario where you have a coupon service that returns a JSON response with a coupon code. The service returns the following JSON:
You can fetch the coupon code and use it in your template as follows:
Usage
Liquid templates are available for both messages sent from Control Panel and API requests.
Control panel
In Pushwoosh, Liquid templates are applicable to all content fields of any channel message:
- Push notifications
- Emails
To add a Liquid Template to your message, insert it into the message’s body. You can do it when working with push or email elements, directly from the Customer Journey Builder interface.
Go to Customer Journey Builder > Create Campaign > Drag and drop the following elements to your canvas: Audience-based Entry, Push (or Email), and Exit. Connect the elements. Then click the Push icon, choose Custom content and insert your copy.
To add the Liquid logic, use tag values with the following syntax:
{% if TagName == ‘value’ %} Content to send in this scenario {% else %} Content to send otherwise {% endif %}
Then click Apply.
Template variables (Pushwoosh Tags) should not contain any spaces and have only alphanumeric values and underscores, e.g., my_tag
or myTag
instead of My Tag
.