Liquid and variables

Every email can use Liquid to fill in names, plans, links, and anything else you know about the person. In the email editor, click {x} to pick a variable, or type it.

What you can use

VariableWhat it holdsWhere
{{ person.properties.first_name }}Any person propertyBroadcasts and automations
{{ event.properties.plan }}A property of the event that started the automationAutomations with an event trigger
{{ variables.reset_link }}Values your code sends, or values earlier steps savedTransactional emails and automations
{{ unsubscribe_url }}The person's link to the preferences pageMarketing emails. See unsubscribes.

A transactional email can't read person properties. Your code sends everything it shows.

Add a default

A property can be missing for some people. Add a default:

liquid
Hi {{ person.properties.first_name | default: 'there' }},

Use single quotes inside Liquid. A double quote inside a link's href ends the address early and breaks the link.

Properties that start with $

Use brackets and single quotes:

liquid
{{ person.properties['$email'] }}

{{ person.properties.$email }} fails, and the email doesn't send.

Show something to only some people

Wrap it in an if:

liquid
{% if person.properties.plan == 'pro' %}
Thanks for being on Pro.
{% endif %}

In the email editor, you can do the same for a whole block: open Who sees it, pick Show only when…, and fill in Only if.

Filters

Filters change a value before it shows, such as upcase, capitalize, date, and truncate:

liquid
Your trial ends on {{ person.properties.trial_ends_at | date: '%B %-d' }}.

PostHog adds a currency filter, which takes a currency code, a locale, or both:

liquid
Your total is {{ variables.total | currency: 'EUR' }}.

The Liquid docs list the standard filters. PostHog turns off the filters that take an expression, such as where_exp and group_by_exp.

When it goes wrong

ErrorFix
TokenizationError: unexpected characterReplace curly quotes, often pasted from a document, with straight single quotes.
expected "\|" before filterA property starts with $. Use person.properties['$email'].
A blank where a name should beThe person doesn't have the property. Add a default.

If Liquid doesn't render, the email doesn't send. Before you go live, pick a real person in Preview as, and send yourself a test.

For the size and send limits on each email, see email and automation limits.

Still have questions?

Was this page useful?