Template tags and variable syntax reference (classic editor)

Last updated at:

You will learn

Learn how to use Klaviyo’s template tags and variables to personalize your marketing messages and provide a customized experience for your subscribers.

Are you using Klaviyo’s new template editor? Head to our new editor resource center.

Klaviyo provides certain template variables that you can use to personalize message subject lines and content. The most commonly used variables are personalization variables, which allow you to dynamically include information about your recipients. For example, their name, email address, or custom properties you've stored about the person.

Hi {{ first_name }}{{ last_name }}, your email is {{ email }} Hi George Washington, your email is george.washington@gmail.com 

Similarly, you can also populate flow messages with event variables. When your flow is triggered by customer behavior or an event, you can dynamically populate your messages with information from this event. This is how you can send messages to customers that feature items abandoned in a cart, recently purchased items, etc.

You can also use different template tags that will produce important links or information. These tags are useful when you want to insert unsubscribe links, dates, and more. Other tags allow you to create content that is only shown if certain conditions are met or allow you to create loops to iterate over content.

{% manage_preferences %} | {% web_view %} Update preferences | View in your browser

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

Hey{{ first_name|default:'friend' }}, any interest in some{{ person|lookup:'Favorite Food' }}?

Hey friend, any interest in some Hawaiian pizza with extra anchovies? 

There are some template tags and variables that are built into the email editor. You can also add template tags in SMS messages by using the Add Property dropdown for template tags, and the Preview Profile Info card in the upper right-hand corner for both template tags and event variables. 

Personalization variables 

Because Klaviyo focuses on people and their preferences, personalization is built into Klaviyo's core and making messages more relevant to each recipient is easy. There are a number of different variables you can use in your emails, SMS messages, subject lines, and more:

First Name {{ first_name }} ex. George
Last Name {{ last_name }} ex. Washington
Email Address {{ email }} ex. george.washington@gmail.com
Phone Number {{ person.phone_number }} ex. 617-555-5555
Organization Name {{ person.organization }} ex. Klaviyo
Customer Title {{ person.title }} ex. Customer Specialist

For any variable, you can add a  default filter to provide a placeholder if there is no variable available to pull in:

Hi {{ first_name|default:'there' }} Hi there  

For values that are proper nouns (i.e. names, locations etc.) then you can also use the  title filter to make sure the first letter is capitalized and all others are lowercase. This is particularly important for first and last names, as these values may not have been entered with the proper capitalization:

Hi {{ first_name|title }} Hi Jessica

Together, the two above would look like:

Hi {{ first_name|title|default:'there' }} Hi Jessica

Custom properties

If you've added extra properties to individual contacts in Klaviyo, you can use them as dynamic content in a message 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.

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.
Your birthday is on {{ person.Birthday|datetime_from_string }} . Your birthday is on Oct. 14, 1985, 8 p.m.

Account variables 

Account variables allow you include information about your company or organization in your email. You can manage this information by navigating to Account > Contact Information > Organization.

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.
Our website is {{ organization.url }}. Our address is www.klaviyo.com.

Event variables 

For flows triggered by an event (Checkout Started, Placed Order, etc.), you can use this event information within the email template.

For example, when a flow is triggered by the Placed Order event, you can thank someone for their purchase and reference the specific item they bought. Klaviyo automatically stores detailed event information for you so that you can use the appropriate variable to add dynamic event content. The information captured is specific to each metric.

When you preview a flow email, you will see all the available properties for that event in the event dialog window that pops up.

If you click on a line of data in the preview window, a small bar will appear at the bottom of the window. This bar will populate with the variable tag that corresponds with the line of data you clicked. You can copy and paste this tag directly into your template. If you are interested in looping through several values for a property (for example, populating a list of all items in a purchase), consider using the block repeat feature.

The event data modal from Klaviyo's flow email editor

For example:

A comparitive chart, with a message as it appears in the template editor (with variable tags), and as it appears once sent (variable tags are replaced by a customer's event data)

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

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?

All of these variables can be used in SMS messages and will populate in the preview with an example. To input this variable in an SMS message, navigate to the right-hand side and click the info button. Then, select the variable you want. When you click the variable, it will be copied to clipboard so you can easily paste it into your message. 


Unsubscribe, manage preferences, web view, preview text

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

When you send preview emails, the tags listed in this section will direct to a placeholder page. In live emails (i.e., campaign, flow, and personal emails), the tags will direct to active pages. 


Klaviyo requires an unsubscribe link in 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.

{% unsubscribe %} Unsubscribe
If you'd no longer like to receive emails, {% unsubscribe 'click here' %} . If you'd no longer like to receive emails,  click here.
This is a fancy <a href="{% unsubscribe_link %}" >unsubscribe</a> link. This is a fancy 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 by navigating to Profiles > Suppressed Profiles and choosing unsubscribe in the reason dropdown.

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.

{% 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 %}" >manage preferences</a> link. This is a fancy manage preferences link.
This will bring recipients to a preference page and submit the preference they select: {% multipreference_link 'Field Property' 'Value from Manage Preferences Page' %} This is best when you would like recipients to be able to select multiple values, like product interests
This will bring recipients to a preferences page and submit the preference they select: {% preference_link 'Field Property' 'Value from Manage Preferences Page' %} This is best when you would like recipients to be able to select a single value, like gender

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.

{% 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 %}" >web view</a>  link. This is a fancy web view link. 

Preview text

In some cases you may want to display your preview text inside the body of your template. You can reference any preview text you set on the email preview screen by using the following email template tag from the dropdown inside a text block:

In the text editor in a Klaviyo template, the Insert Tag dropdown is active with a cursor hovering over the Preview Text option

You can also manually add preview text by pasting in the following tag:

{% render_variable preview_text %}

If you update the preview text on the email preview screen, this tag displays your updated preview text.

Date tags 

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

Current Day of Month {% current_day %} ex. The current day of the month is 5.
Current Day of Week {% current_weekday %} ex. The current day of the week is Friday.
Current Month {% current_month_name %} ex. The current month is September.
Current Year {% current_year %} ex. The current year is 2017.

Currently, we only support English names for months and weekdays.

Parse property as date

The format_date_string tag parses and converts a string to a date so you can use the date filter to format it.

Birthday {{ person|lookup:'Birthday'|format_date_string|date }} ex. Your birthday is on Oct. 14,1985

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 campaign is an autoresponder triggered by what someone did, include information from that event.

If-else blocks

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

{% if person|lookup:'Interested in Dogs?' and not person|lookup:'Interested in Cats?' %}  

 Like dogs? Check out some great toys for your canine.

{% elif person|lookup:'Interested in Cats?' and not person|lookup:'Interested in Dogs?' %}  

 Like cats? Check out some great toys for your feline.

{% else %}

Check out some great toys for your pet!

{% endif %}

In the example above, a person will be shown the first line of text if "Interested in Dogs" is true and "Interested in Cats" is false, the second line of text if "Interested in Cats" is true and "Interested in Dogs" is false, or the third line if they don't fit either of those conditions.

For blocks

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

{% for item in event.shopping_cart_items %}{{ item.name }}  × {{ item.quantity }}{% endfor %} . Oversized Beach Blanket × 1 Beach Chairs × 430 SPF Sunscreen × 220 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 these cases, after the filter use a colon (:) and then surround the argument with quotes.

For more in-depth instructions, review our guide on Using Filters to Customize Template Tags and the Glossary of Variable Filters.

Below are some common use cases and examples:

Lookup filter {{ person|lookup:'Birthday' }}

The lookup filter allows you to look up a certain property about someone. For example, if you use the tag in the example above, this will autopopulate with whatever the person's birthday is.

> gt
< lt
>= gte
<= lte

These filters will allow you to identify people who have properties greater than, less than, greater than/equal to, or less/than equal to a particular value. For example, if you use the tag {{ person|lookup:'age'|gt:25 }}, this will allow you to identify people who are older than 25.

You could also use this to identify people who have a property that is greater than whatever that property's maximum/minimum limit is. For example, the {{ person|lookup:'age'|gt:min_age_limit }} will allow you to identify people who are older than the lowest value for the "age" variable, so long as this is a number.

Default filter  {{ first_name|default:'friend' }}

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

Split filter {{ product_type|split:' - '|lookup:0 }}

The split filter is used to split the variable you pass into a zero-indexed array based on the value you pass. For example, if you have a property with the value "Shirt - Large," large is the "lookup:0" value.

To format the date of an event variable add the filter: |slice:':10'|datetime_from_string|date:'d/m/Y'

On {{ event.extra.customer.updated_at|slice:':10'|datetime_from_string|date:'d/m/Y' }}
On 10/12/2015


You can use this filter like the "add" filter, but instead of forcing everything to integers, it'll keep the decimal points and do the addition.


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.

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

Klaviyo special properties

If you are using our API to set properties on a user's profile, Klaviyo has a few built-in fields you can set with the Identify API, our Profiles API, or via a CSV import:

  • $id: your unique identifier for a person (up to 64 characters)
  • $first_name: first name
  • $last_name: last name
  • $phone_number: phone number
  • $title: title at business or organization
  • $organization: business or organization
  • $city: city
  • $region: region or state
  • $country: country
  • $zip: postal code
  • $address1: address line 1
  • $address2: address line 2
  • $timezone: time zone
  • $email: email address
  • $source: where a contact came from
  • $latitude: latitude
  • $longitude: longitude

Additional resources

Was this article helpful?
1324 out of 2158 found this helpful