Inserting merge tags using Liquid in my emails
Personalization is one of the best ways to make your email or push messages more engaging and impactful. To provide you with powerful personalization options, Vero uses Liquid, an open-source templating language created by Shopify. You can use Liquid to load dynamic content in your emails based on the customer or event properties you have stored in Vero.
Merging basic data
In Vero, we use a prefix within the standard Liquid {{
template fields to denote where to load the data from. The two main prefixes for loading customer data:
{{user.property}}
replace attribute with the name of any customer property that you've captured using the Vero API or uploaded via CSV. For example,{{user.first_name}}
would printJohn
for a user profile that has the attributefirst_name
with valueJohn
.{{event.property}}
replace attribute with the name of any event property you've captured with our API or uploaded via CSV. For example,{{event.product_name}}
would printApple MacBook Pro
for an event that has the attributeproduct_name
with valueApple MacBook Pro
.
Note: You can only access event attributes for the trigger event of a triggered email.
The prefixes user. and event. indicate whether the property being loaded is stored against the customer's profile as a customer property or against an event the user has triggered.
Merge tags are replaced dynamically with the correct data when an email is prepared to be sent.
Merging event properties in emails
For example, Reba viewed Red Shoes would be {{user.first_name}}
viewed {{event.product_viewed}}
.
You can only insert event properties attached to the base event - that is, the event that triggers a Behavioral or Transactional campaign. You can view the list of properties you already track using our API by visiting the Logs page in Vero and selecting View Data under the drop down associated with a particular event line item.
For example: the event added product to cart might have a number of properties including product_name and image_url.
When creating campaigns in Vero – whether you're using templates or standard rich text – you can insert dynamic variables using the Liquid Templating Language.
With all of the following variables, you can use the fallback option, such as {{user.first_name | fallback: 'there'}}
as the option to use if the value is blank.
Vero specific merge data
There are some merge fields that support key Vero functions, including Vero's one-click unsubscribe and View in browser (permalink) tools.
The following is a list of the key variables and functions you can use:
{{url.unsubscribe_link}}
inserts a URL (e.g. http://getvero.com/unsubscribe/xyz) that unsubscribes your customers in one click.{{url.unsubscribe}}
inserts an anchor<a>
tag containing the string Unsubscribe and pointing to the link referenced by{{url.unsubscribe_link}}
above.{{url.permalink_link}}
inserts a URL (e.g. http://getvero.com/view-online/xyz) that points to an online, hosted version of each individual email that is sent through Vero.{{url.permalink}}
inserts an anchor<a>
tag containing the string View in browser and pointing to the link referenced by{{url.permalink_link}}
above.
Using Liquid functions
Liquid is a complex and powerful templating language. Vero supports most of the functions outlined in the Liquid for Designers documentation.
We have extended the default functionality with a series of custom Liquid functions designed to help build better emails whilst making your life easier. Vero-specific Liquid functions:
{{ user.email | encode }}
allows you to URL encode the provided value. If user.email was equal to damien+test@getvero.com it would be rendered asdamien%2Btest%40getvero.com
after encoding.{{event.invoice_ref | format: '%05d'}}
allows you to reformat numerical variables (integers, floats, octal numbers, strings, unsigned decimals and hexadecimals). You can use any formatting from the print format cheat sheet.{{event.price | precision: 2}}
allows you to change the precision of integers. As an example, 2.0554 would become 2.06 with a precision of two.{{event.price | delimiter: ',' }}
allows you to format numbers so that they include commas. For example, you could do{{ 4000 | delimiter: ',' }}
and we'd render 4,000.{{ event.purchase_date | time_zone: 'Sydney' | date: '%d/%m/%Y %H:%M:%S %Z' }}
allows you to change the timezone and format of an attribute. The attribute must be a number. You can use any of the timezone values from the TZ column of this guide to timezones. This time formatting tool can help you build the formatting string for output.{{ extra.time.now | date: '%Y' }}
gives you the current year. This is commonly used in copyright footers.
You can find our Liquid Language Guide here.
Inserting even more powerful data in your emails
There are times when you'll want to go beyond the data you push and store in Vero.
Imagine the scenario where you have triggered a behavioral email three days after a user has taken a specific action, yet want to include the latest products available in your store.
Imagine the scenario you want to send an email every Tuesday and pull in the latest articles from your blog.
Vero's most powerful dynamic templating functionality is called Fusion and allows you to pull in data from your own internal APIs or public API endpoints just before an individual email is sent. This provides the data accuracy and timeliness needed to personalise your emails on a truly one-to-one basis. Examples include:
- Product recommendations tailored specifically to each customer
- Data and html charts that deliver unique weekly updates with usage details
- Delightful details like weather and location pulled from services such as OpenWeather and Clearbit
You can learn more by reading our full help article on Fusion.