How to Insert Template Tags and Variables into Text Blocks (new editor)

read
Last updated at:

Overview

Learn how to add template tags and variables to email templates. You can add these tags to your templates by typing them directly into a text field, copying them from the email preview modal, or by using the Add personalization menu in a text block. Use these tags and variables to include things like a recipient’s first name, custom properties, an unsubscribe link, and more. 

Access Klaviyo’s new template editor from the Email Templates tab by clicking Create Template > Use New Editor. After creating a template with the new editor, you can customize and send it as a campaign or use it in flow emails by selecting the new template in the campaign or flow setup process.

In the coming weeks, you’ll have the option to convert your existing email templates to the new template editor as well.

Before Starting

Before you get started, it’s helpful to understand how variables work within Klaviyo. The variables available in your account are different from the variables in anyone else’s Klaviyo account, and are dependent on the data you store in Klaviyo. 

You can store and use a small handful of default Klaviyo properties (like first and last name), along with an unlimited number of custom profile properties and dynamic event data. To see all of the tags available in your own account, follow the steps for adding variables through the personalization menu or the preview modal below. 

Add Tags Using the Add Personalization Menu

To add a template tag or personalization variable without copying, pasting, or typing anything, use the Add personalization menu. 

Open a text block and click the profile icon. A searchable dropdown menu will appear with a list of template tags and profile properties. Scroll through the tags or search to find the one you’d like to add, then click it to add it to your template. 

Add_variable.gif

Add Variables From the Preview Modal

You can add profile property and event variables by copying them from the preview modal and pasting them into your message. 

Adding Profile Property Variables

To add a profile property variable from the preview modal: 

  1. Click Preview and test from the template editor 
  2. Click Search for a profile and enter the email of a profile that includes the variable you’d like to add; note that you’ll only copy the variable name from the sample user’s profile, and each recipient of the email will see information from their own profile 
  3. Scroll through their Profile properties and Custom properties until you find the variable you’d like to use
  4. Hover over the variable’s name until you see the message Copy {{ person.variable_name }} variable, then click to copy it
  5. Click Done
  6. Paste the variable into a block in your template

Adding Event Variables

To add an event variable from the preview modal:

  1. Click Preview and test from the template editor 
  2. Under Preview data source, click Event
  3. Select an event from the dropdown
  4. Scroll through the Event properties until you find the variable you’d like to use; if you don’t see the variable you need, use the arrows to the right of Previewing with recent event: to select a different instance of the event
  5. Hover over the variable’s name until you see the message Copy {{ event.variable_name }} variable, then click to copy it
  6. Click Done
  7. Paste the variable into a block in your template

You can also paste in variables from other areas (e.g., other templates or a Klaviyo Help Center article). If you paste a variable from elsewhere, make sure to paste it as plain text using Command+Shift+V or Control+Shift+V. This will ensure no formatting is pasted along with your text, which can introduce code errors and increase the size of your message. 

Manually Adding Variables

If you know a variable’s name, you can add it by typing it into a text field directly. Klaviyo variables use the following structures: 

Variable type

Sample Format

Profile properties (no spaces or special characters)

{{ person.variable_name }}

Profile properties (any)

{{ person|lookup:'variable name')

Event properties (no spaces or special characters)

{{ event.variable_name }}

Event properties (any)

{{ event|lookup:'variable name' }}

Setting a Default Value

You may not always have complete information for every email recipient you contact. For example, you might have some subscribers’ first names, but not others. To avoid blank spaces in your emails for those recipients with incomplete data, use the default filter to set a backup. 

To add the default filter, add the following after your variable name: |default:''

Then, add your default variable between the single quotes. In an email, this might look like: 

Hey {{ first_name|default:'friend' }}! 

When the message is sent, any recipients whose names are not stored in your database will see this message: 

Hey friend! 

Learn more about using filters to customize your variables

Learn More About Template Tags and Variables

To take a deep dive into how template tags and variables work in Klaviyo, head to our Guide to Template Tags and Variable Syntax

Additional Resources



x
Was this article helpful?
0 out of 1 found this helpful