Message Personalization (Liquid)
Last updated
Last updated
Liquid is an open-source template language developed by Shopify. FlareLane supports personalized messages using Liquid. With Liquid, you can manipulate data into the desired format, enabling richer and more flexible personalization in your messages.
Try adding customer data such as names or membership levels to your messages to deliver a more personalized experience. This often leads to higher engagement compared to generic messages.
Examples of personalized messages:
Hello {{ name | default: "Customer" }}!
Your registration was completed on {{ tags.signup_date | date: "%Y-%m-%d", "America/Los_Angeles" }}.
The product you ordered, {{ entry_event.data.product_name | truncate: 20 }}, has been shipped.
Your reward points of {{ tags.point | number_with_delimiter }} USD are about to expire.
The Liquid syntax is a string block enclosed in double curly braces. For example, a personalized message using the customer’s name can be written as:
{{ name | default: "Customer" }}, hello!
At the time of sending, if the user profile contains a name value, the message will be delivered like this:
John, hello!
If the name data is missing, the default value will be used, and the message will be delivered as:
Customer, hello!
Filters can be chained together. In the example below, if the signup_date
tag exists, it is formatted as a date. If the value is missing, the default
filter returns a fallback value:
Your registration was completed on {{ tags.signup_date | date: "%Y-%m-%d", "America/Los_Angeles" | default: "today" }}.
default
– Replaces a missing variable with a default value.
truncate
– Truncates a long string to a specified length.
truncatewords
– Truncates a long string by the number of words.
replace
– Replaces all occurrences of a specific substring in the variable.
replace_first
– Replaces only the first occurrence of a specific substring.
upcase
– Converts all characters in a string to uppercase.
downcase
– Converts all characters in a string to lowercase.
capitalize
– Capitalizes the first word in a string.
url_encode
– Encodes a string to be URL-safe.
url_decode
– Decodes a URL-encoded string.
strip_html
– Removes all HTML tags from a string.
number_with_delimiter
– Converts a number into a string with comma separators every three digits.
plus
– Adds a specific value to a number variable.
minus
– Subtracts a specific value from a number variable.
times
– Multiplies a number variable by a specific value.
divided_by
– Divides a number variable by a specific value.
round
– Rounds a number to the nearest integer.
floor
– Rounds a number down to the nearest whole number.
ceil
– Rounds a number up to the nearest whole number.
first
– Returns the first value in the array.
last
– Returns the last value in the array.
size
– Returns the number of items in the array.
join
– Combines all values in the array into a single string.
{% if %}
{% else %}
{% elsif %}
– Used to handle conditional logic and create branching flows based on specific conditions.
{% assign %}
– Assigns a value to a temporary variable, which can be reused in later expressions or filters.
Example:
{% assign user_name = tags.nickname %}
{% assign last_purchase = tags.last_purchase_category %}
{% if last_purchase == "Sneakers" %}
This week only, we’re offering 10% off the latest sneakers that {{ user_name }} loves! Don’t miss out 👟
{% elsif last_purchase == "Outerwear" %}
New outerwear perfect for the cold weather has arrived! Special perks are ready just for you, {{ user_name }} 🧥
{% else %}
New arrivals and exclusive discounts are waiting just for you, {{ user_name }}. Check them out now!
{% endif %}
You can use various integrated customer data as variables in your messages:
Tags: tags.*
Automatically maps to matching tags set in the user profile or device.
Example:
{{ tags.grade }}
– A coupon for your {{ tags.grade }} membership level has been issued.
→ Looks up the grade
tag among the user's tags.
Events: entry_event.data.*
Variables attached to the trigger event in customer journey automation can be used in messages.
Example:
The item {{ entry_event.data.product_name }} in your cart is still waiting for you!
→ Retrieves product_name
from the event’s attached data.
UserId
If the target device has a user ID, the value is passed. This is often used when user IDs need to be included in webhook calls or similar use cases.
Data
You can inject external values at the time of sending to personalize messages.
Example:
{{ writerName }} liked your post.
→ The value of writerName
can be added via the data
parameter in the API or entered manually in the console.
API
POST https://api.flarelane.com/v1/projects/<project-id>/notifications
{
targetType: userId,
targetIds: "USER_ID",
body: "{{ writerName }}likes your post."
data: {
writerName: "johndoe"
}
}