HomeGuidesAPI Reference
ChangelogHelp CenterCommunityContact Us
Guides
These docs are for v2022-10-17. Click to read the latest docs for v2024-10-15.

Message design overview

Learn about template variables, tags, and filters for message design in Klaviyo

Customizing and personalizing your emails

Klaviyo supports a large number of message template tags (sometimes called merge tags) that you can use. More specifically, Klaviyo supports most of the filters used by the Django template language, along with some custom ones as well. For a more comprehensive guide to using the Django template language in a Klaviyo context, see our Getting started with template tags and variable syntax. You can also check out our how-to on using filters to customize variables and our glossary of variable filters.

Terminology — variables, tags and filters

When creating message templates, Klaviyo provides a few different ways to customize content so it looks great and is more relevant to your recipients. Klaviyo provides template variables you can use to personalize the content. The most commonly used variables allow you to include information about the recipient, such as their name, email address or custom properties you've stored about that person.

In addition to variables, you can also use different template tags that will output important links or information. These tags are useful when you want to insert unsubscribe links, share links, dates and more. Other tags allow you to create that is only shown if certain conditions are met or allow you to create loops to iterate over content. A few examples are on the right, but a full list of available tags, grouped by function, is below.

Finally, Klaviyo provides template filters that are used with template variables to provide additional functionality, including accessing custom properties for recipients, default values and additional formatting options.

TypeTemplateOutput
Template Variable Hi {{ first_name }} {{ last_name }}, your email is {{ email }}...Hi George Washington, your email is [email protected]...
Template Tag {% manage_preferences %} | {% web_view %}Update preferences | View in your browser
Template FilterHey {{ first_name|default:'friend' }}, any interest in some {{ person|lookup:'Favorite Food' }}?Hey friend, any interest in some hawaiian pizza with extra anchovies?

Personalization variables

Because Klaviyo focuses on people and what they're up to, personalization is built into Klaviyo's core and making emails more relevant to reach recipient is easy. There are a number of different variables you can use, along with an unlimited number of custom properties. Additionally, you can choose a default value to fill in for missing values

First Name

In the first example, the person we're sending to has the first name "George." In the second example, we don't know the recipient's first name, so we use the default filter to provide a placeholder.

TemplateOutput
Hi {{ first_name }}, ...Hi George, ...
Hi {{ first_name|default:'there' }}, ...Hi there, ...

Last Name

You can also use someone's last name the same way as first name.

TemplateOutput
Your last name is {{ last_name }}.Your last name is Washington.

Full Name

Or, if you want someone's entire name, you can get their full name.

TemplateOutput
Your full name is {{ full_name }}.Your full name is George Washington.

Email Address

This one's pretty self-explanatory.

TemplateOutput
Your email address is {{ email }}.Your email address is [email protected].

Custom properties

If you've added extra properties to individuals, you can use them with the person variable and the lookup filter. It's usually a good idea to also provide a default value in case someone doesn't have the custom property you're trying to use by including the default filter.

TemplateOutput
Your favorite color is {{ person|lookup:'Favorite Color' }}.Your favorite color is blue.
Your favorite TV show is {{ person|lookup:'Favorite TV Show'|default:'unknown' }}.Your favorite TV show is unknown.

Account variables

Account variables allow you include information about your company or organization in your email. You can manage this information on your account page.

TemplateOutput
You received this message from {{ organization.name }}.You received this message from the United States of America.
Our address is {{ organization.full_address }}.Our address is 1600 Pennsylvania Avenue Washington D.C. 20500.

Event variables

For flows based on metrics, templates also have a variable that represents the event that triggered that email. This allows you to use information about that event in your email. For example, if you want to thank someone for their purchase and reference the specific products they bought, you can easily do that with Klaviyo.

If you're sending events to Klaviyo via the API, all of properties for those events are available through the event variable and lookup filter.

For integrations with other services, Klaviyo automatically stores detailed information for you. The information captured is specific to each service and metric. You can see what properties are available while you're creating your flow email by clicking on "Preview." In that dialog, we'll show you the properties for that event.

TemplateOutput
Thanks for your purchase of ${{ event|lookup:'total_price' }}.Thanks for your purchase of $29.00.
How do you like your new {{ event|lookup:'Items Purchased' }}?How do you like your new blue suede shoes?

List and campaign tags

List and campaign tags allow recipients to manage their subscription preferences and view your campaign in their browser.

Unsubscribe

Klaviyo requires an unsubscribe link on all campaigns. To include an unsubscribe link, you can use the unsubscribe tag. By default, the link will have the text "Unsubscribe." If you want to customize the text in the link, this tag takes an optional parameter that allows you to customize the text. If you need even more control, there is also a tag that provides only the URL for the unsubscribe link.

When a recipient clicks the unsubscribe link, they're taken to a page to confirm their unsubscribe request. You can see everyone who has unsubscribed in the People section of Klaviyo.

TemplateOutput
{% unsubscribe %}Unsubscribe
No longer want to receive these emails? {% unsubscribe 'click here' %}.If you'd no longer like to receive emails, click here.
This is a fancy <a href="{% unsubscribe_link %}" style="color:red;">unsubscribe</a> link.This is a fancy unsubscribe link.

Web View

To give recipients a link to a web page that has your campaign, you can use the web view tag. Like the unsubscribe tag, if you need more control, there is also a version that just provides the URL.

TemplateOutput
{% web_view %}View in Your Browser
Can't see this email? {% web_view 'Open in your browser' %}.Can't see this email? Open in your browser.
This is a fancy <a href="{% web_view_link %}" style="color:blue;">web view</a> link.This is a fancy web view link.

Manage Preferences

For standard lists, you can create a preferences page and customize it to match your brand. This allows recipients to update their preferences. To include a link to this page for each recipient, use the manage preferences tag. If you need more control, there is also a version that just provides the URL.

TemplateOutput
{% manage_preferences %}Manage Preferences
Want to update your preferences? {% manage_preferences 'Click here' %}.Want to update your preferences? Click here.
This is a fancy <a href="{% manage_preferences_link %}" style="color:orange;">manage preferences</a> link.This is a fancy manage preferences link.

Date tags

Date tags give you a quick way to insert the time of a campaign into an email. The date is in the timezone of your account.

Current Day

Inserts the current day of the month.

For example, first day of the month would be: 1.

TemplateOutput
The current day of the month is {% current_day %}.The current day of the month is 1.

Current Day of the Week

Inserts the current day of the week. Currently, we only support English names.

Example: Sunday.

TemplateOutput
Today is {% current_weekday %}.Today is Sunday

Current Month

Inserts the current month.

For example, January would be: 1

TemplateOutput
The current month is {% current_month %}.The current month is 1.

Current Month Name

Inserts the name of the current month. Currently we only support English names.

Example: January.

TemplateOutput
The current month is {% current_month_name %}.The current month is January.

Current Year

Inserts the current year.

Example: 2021

TemplateOutput
The current year is {% current_year %}.The current year is 2021.

Conditional tags

Conditional tags allow you to conditionally include content in your campaigns. They give you powerful controls for personalizing your campaigns to each individual recipient and, if your email is a flow triggered by what someone did, include information from that event. For a deeper dive into conditionals, head to Use Conditionals In Messages.

If-else blocks

If-else blocks allow you to control what content someone receives in their email based on a variable's value.

TemplateOutput
{% if person|lookup:'Interested in Dogs?' %}
Like dogs? Check out some great toys for your canine.
{% else %}
Like cats? Check out some great toys for your feline.
{% endif %}.
Like dogs? Check out some great toys for your canine.

For blocks

For blocks allow you to iterate over each the item in a variable that's storing a list and render them individually.

TemplateOutput
{% for item in event.shopping_cart_items %}
{{ item.name }} × {{ item.quantity }}
{% endfor %}.
Oversized Beach Blanket × 1
Beach Chairs × 4
30 SPF Sunscreen × 2
20" Plastic Cooler × 1

Basic filters

Filters allow you to modify how a variable is displayed. You'll notice they go directly after a variable. The variable and filter should be separated with a pipe character |. Some filters take an argument. In those cases, after the filter use a colon : and then surround the argument with single quotes ' '.

Below are some common use cases and examples.

Lookup

This filter is used for looking up properties on people or events.

TemplateOutput
{{ person|lookup:'Birthday' }}.July 8th
${{ event|lookup:'Total Spent' }}.$19.99

Default

This filter is used to specify a default in case a variable doesn't have a value. This is useful as placeholder when you don't always have the information you want to use, e.g. someone's name.

TemplateOutput
Hi {{ first_name|default:'friend' }}, ...Hi friend, ...

Floatformat and other Django filters

In addition to all the filters above, Klaviyo supports most of the filters used by the Django template language. As an example of one of the filters included, the floatformat filter allows you to format numbers.

TemplateOutput
You earned {{ event|lookup:'Points Earned'|floatformat:1 }} points.You earned 25.5 points.

Additional resources