Personalize Flow Emails with Dynamic Event Data

Last updated at:


You can create personalized flow emails by using dynamic event data. For instance, you could use event data in an Abandoned Cart flow email to show individuals what product they left behind, an image of the item, and more. This allows for a more personalized experience for the customer, as well as a higher chance of conversion.

In this article, you will learn what dynamic event data is, when to use it, where to find it, and how to include it in your flow emails.

About Event Variables

When you have an integration with a third-party service or tool, Klaviyo records certain metrics when a customer profile takes an action. What actions Klaviyo tracks depends on your integration, but common ones include Started Checkout, Placed Order, and Viewed Product. In addition, each metric recorded in Klaviyo includes relevant information about the event, which is called metadata.

For example, when a customer begins to check out, Klaviyo will track this as a Started Checkout event. Klaviyo is periodically sent details from the third-party platform about the item(s) left in the cart, quantity of each item, total, images, etc. In Klaviyo, this data is stored as event variables and includes all of the information associated with an action a specific customer took.

When You Can Use Event Variables

Because event variables are based on a customer’s behavior, they can only be used in metric-triggered flow emails.

List-, segment-, and date property-triggered flows are not triggered by events, but by information about the customer in their profile. Thus, there are no event variables to pull from and use in a flow email. Similarly, event variables cannot be used in campaigns, as these are manual, one-time sends and are not based on the action a customer took.


Common examples of metric-triggered flows include:

How to Find Event Variables

In a flow, you first need to select the email in which you want to show the dynamic event data. Next, click Configure Content > Edit Content.


Once in the email template editor, click Preview on the left-hand side. You’ll see a popup saying, Choose a recent event to preview with. In the window, you will see a recent event that corresponds with the flow's trigger. For example, in an Abandoned Cart flow email, the preview window will show a recent Started Checkout event. If you want to look at the data for a different event, toggle left and right using the arrow buttons.


This preview window will show all of the data available for that particular event metric. To view a specific event variable, click on any line of data to reveal the associated template variable. The variable will appear within a gray box at the bottom of the window. List entries are numbered starting at 0 (not 1, as this information is brought over in an array), and this number does not equal the item quantity. For instance, if {{ }} is the variable entry for an image, the 0 indicates that it is the first item in the array (and not that there is no product images)

To use event variables, you must copy them exactly. Event variables are case-sensitive, and the slightest deviation from how it appears in the preview window could cause the variable not to work.


If you want to view the dynamic event data for an item in an abandoned cart email, click the first item under Items. In this case, the first item is MATTE COLOR LIP BALM - PEACH and the variable is {{ event.Items.0 }}.


Event Variable Arrays

If you add the variable above to an email, you can pull in the dynamic data for the first item left in the cart. It is similar to going up to a line of people and asking the first person their name. This approach works well if there can only be a single item; however, it is time-consuming for multiple items or when you don’t know how many items someone might add.

Ideally, you would want to use a single command to get all of the event variables for items within a group instantly -- like being able to call out “Name” and getting the names of everyone in a long line.

When it comes to a list of event variables, arrays allow you to do just that.

An array occurs when there are multiple entries under one umbrella property (like multiple items in an order). As mentioned above, the first item will have a "0" at the end (or potentially in the middle), the next item will have a "1," and so on. Using an array, you can capture information about both the umbrella property (e.g., Items or Collections) and the individual entries under that property.

In the example below, there are three items in the preview for a Placed Order event:

  • The variable for the "Sweet Tarts" item is {{ event.Items.0 }}
  • The variable for the "Runts" item is {{ event.Items.1 }}
  • The variable for the "Nerds" item is {{ event.Items.2 }}

For this example, the event variable array for these items is event.Items.


Another example is an event variable for an image, which allows you to display a dynamic image of a product.


For {{ event.extra.line_items.0.product.images.0.src }}, the list for the image (blue) is event.extra.line_items — also called the collection or variable array — and the image itself (orange) is product.images.0.src in that list. Yellow indicates the array number.

Common Examples of Event Variables

The syntax for different event variables depends on both the integration and event metric. You can see the syntax for all of the available variables for a given event by scrolling through the preview window and clicking on the different entries.

Some common examples of variables by integration are listed below for aStarted Checkout event. Keep in mind that the exact variable may differ depending on the metric used to trigger the flow. 

Product Name/Title {{ }}
Product URL {{ event.extra.items.0.product.url }}
Image {{ event.extra.items.0.product.images.0.src }}
Price for Product  {{ event.extra.line_items.0.product.price }
Quantity {{ event.extra.line_items.0.quantity }}
Total {{ event.extra.total_inc_tax }}

Magento 1

Magento 2

Product Name/Title

{{ }}

{{ }}

Product URL

{{ event.extra.line_items.0.product.key }}

{{ event.Items.0.Product.FullURL }}


{{ event.extra.line_items.0.product.images.0.url }}

{{ event.extra.line_items.0.product.images.0.url }}

Price for Product 

{{ event.extra.items.0.base_original_price }}

{{ event.extra.line_items.0.product.price }}


{{ event.extra.line_items.0.quantity }}

{{ event.extra.line_items.0.quantity }}


{{ event.extra.base_grand_total }}

{{ event.extra.base_grand_total }}

Product Name/Title {{ event.extra.line_items.0.product.title }}
Product Handle {{ event.extra.line_items.0.product.handle }}
Image {{ event.extra.line_items.0.product.images.0.src }}
Price for Product  {{ event.extra.line_items.0.line_price }}
Quantity {{ event.extra.line_items.0.quantity }}
Total {{ event.extra.customer.total_spent }}
Product Name/Title {{ event.extra.Items.0.Name }}
Product URL {{ event.extra.Items.0.URL }}
Image {{ event.extra.Items.0.Images.0.URL }}
Price for Product  {{ event.extra.Items.0.LineTotal }}
Quantity {{ event.extra.Items.0.Quantity }}
Total {{ event.extra.Items.0.TotalWithTax }}

*You can rebuild carts from an Abandoned Cart flow in WooCommerce by using the parameter ?wck_rebuild_cart={{ event.extra.CartRebuildKey }}. Cart rebuilding is also available for Shopify and Magento 1 integrations but is pregenerated in the default Abandoned Cart flows.

Below, we discuss two different ways of iterating over these or other event variable arrays:

  • Using the Block Repeat feature
  • Creating a dynamic table

Using the Block Repeat Feature

The Block Repeat feature allows you to add a single block (text, image, etc.) that will automatically repeat itself and iterate over all entries in a property array.

First, go to the preview window to grab the event variable you want the block to iterate over. Here, we chose event.Item.

Next, drag a block into your email and click the gray "hamburger" icon in the upper left-hand side (between the question mark icon and Cancel button). Paste the event variable into the Repeat For box and give the variable an alias -- in this case, item is the alias.


Switch the feature to On before clicking the Save button. You will then see the feature icon turn dark gray.

In the text box, insert the variable alias {{ item }} and save it. When you preview the template, you will see that all the value entries will populate as this variable is looped over.


Another example is using the Block Repeat feature with a table, such as in the example below.


Building a Dynamic Table

If you want to create a more complex block featuring dynamic content, you can build a dynamic table. A dynamic table loops over all entries for a single variable array. For example, if a customer abandons a cart with multiple items, those items will all be displayed in the table. A dynamic table also allows you to create a table of information that repeats (if necessary).

In Klaviyo, there are several built-in flows that contain emails in which dynamic tables are already set up, including the Abandoned Cart, Customer Winback, and Product Review / Cross Sell flows. You can also create these tables yourself if you are familiar with the event variables for your integration.

Step One: Adding a Dynamic Table

First, drag a table block into your email. Typically, you will want to delete the third column and column headers within the block columns as well as the divider, which can be adjusted under the Block Styles tab.

Next, go to Rows. Before inserting any text in the table, switch the table from Static to Dynamic. If you have already written a message in one of the cells, copy the message prior to changing the table to Dynamic, as doing so will automatically erase the contents of a table.


Step Two: Capturing the Event Variable

Go into Preview tab to pull up the available dynamic variables. Then, scroll down to the title for one of the products abandoned in a cart to find the event variable: {{ event.extra.line_items.0.product.title }}. This contains more information about the product than {{ event.Item }}, which is simply the name of the item.


In the image above, the text highlighted in blue is the variable array, yellow is the array number, and orange is the specific variable you want to pull. 

Step Three: Establishing a Data Source for the Dynamic Table

Click Data Source. Here, you will be able to input a Row Collection field, which is the variable array you want to repeat, as well as the Row Alias. By default, they say Items and item, respectively.

You can leave the alias as is, but for Row Collection, paste in the event variable array. Remove the brackets on both sides as well as the number and following text. For example, {{ event.extra.line_items.0.product.title }} becomes event.extra.line_items. This shortened form is called the collection.


Step Four: Including a Dynamic Product Title

After the data source is set up, you can move on to using variables to include text in your email. Since this email is for an abandoned cart flow, it’s important to show the name of the product left behind.

To input the product title into the text, navigate to one of the columns. If you want an image in the first column and the text in the second, click on Column 2.

Next, paste in the full event variable once again. This time, replace the collection for the variable (i.e., the text you used for the Row Collection) as well as the following number with the Row Alias, and don’t delete the surrounding brackets. For this example, {{ event.extra.line_items.0.product.title }} now becomes {{ item.product.title }}, since item is the alias.


Once you finish the steps above, preview the email to ensure that the title shows up. If it doesn’t appear, double-check the spelling, capitalization, and formatting of the text here and in Data Source against the variable shown in the preview window.

Step Five: Adding an Image

To insert a dynamic image, you need to find the event variable for the image in the preview window. Often, this variable is listed under image, img, or src, but it depends on your integration. Here, it is under src: {{ event.extra.line_items.0.product.images.2.src }}. Note in this tag, we are specifically referencing the third image (0, 1, 2, etc.) in the event variable array that holds images (event.extra.line_items.0.product.images). This is an event variable array within the event variable array event.extra.line_items, which holds the images for this specific item.

Once you have this variable, head to the column where you want to display the image (Column 1, in this case) and change it from Text > Image. Choose Browse and then select Placeholder.


Input the image event variable, replacing the collection and following number with the alias; here, {{ event.extra.line_items.0.product.images.2.src }} becomes {{ item.product.images.2.src }}. Then, click Save.

Note that if there’s a number near the end (such as the 2 in this example), it should not be removed.


In addition, check the Fit Image Area checkbox and set the pixel size (250 px is good in most cases).


Once you finish making changes, click Save and preview your image to make sure it appears as expected. If an image doesn’t appear, check the spelling of the variable under Placeholder against the one in the preview window.

Step Six (Optional): Showing the Quantity and Total of a Product

If you want to show the quantity and total price for each product, navigate back to the column where you added the product title.

Type in “Quantity:” in the text box. Next, navigate to the preview window to find the event variable -- for example, {{ event.extra.line_items.0.quantity }}.

After exiting this window, paste the variable next to “Quantity”, replacing the collection and number with the alias.

For the total, use the line_price event variable (e.g., {{ event.extra.line_items.0.line_price }}), which will show the total price of a product based on the quantity. For instance, if you have a lipstick that costs $12, and someone has added two of them, the line price will show as $24.


As with the quantity, write in “Total:” and replace the collection with the alias. To display the currency, either add in the currency symbol before the brackets — for instance, ${{ item.line_price }} —or add % currency_format inside the brackets and before the event variable, as well as another % before the closing brackets — for example, {% currency_format item.line_price %}. Note that the currency format tag cannot be used with  the float format tag.


By default, numbers will be shown as X.0. If you’d like to change this format, you can do so with the float format tag. Adding |floatformat:0 into the brackets will get rid of the decimal point and following number while |floatformat:1 will display with one number after the decimal point, |floatformat:2 will display with two, and so on.


Step Seven (Optional): Linking to the Product Page

To link either a dynamic image or text to the associated product page, head to the preview window and locate the event variable for the product handle.


Depending on the properties passed on the event, the structure of this link may differ. For example, an event property may contain the full URL to a product or it may only contain the path, in which case it will need to be combined with the store URL. Below, we've laid out what the product link would look like for the Started Checkout event from our more common integrations when item is the Alias.

  Event Variable Final Tag
BigCommerce {{ event.extra.items.0.product.url }} {{ organization.url }}{{ item.product.url }}
Magento 1 {{ event.extra.line_items.0.product.key }} {{ organization.url }}{{ item.product.key }}
Magento 2 {{ event.Items.0.Product.FullURL }} {{ item.Product.FullURL }}
Shopify {{ event.extra.line_items.0.product.handle }} {{ organization.url }}products/{{ item.product.handle }}
WooCommerce {{ event.extra.Items.0.URL }} {{ item.URL }

If you use the organization.url tag, you must set your link protocol to <Other> instead of http or https.

You may notice when using {{ organization.url }} to show a certain product that it leads to a broken link. This happens because Klaviyo populates your website URL in the template using the {{ organization.url }} tag, which pulls directly from the URL you have inserted in your account settings. Removing the forward slash (/) in your account settings can resolve this issue. 


Alternatively, you could type out your store URL directly followed by products/ and the variable for the item product handle (for example, {{ item.product.handle }}).


Step Eight: Previewing Your Email

After completing the steps above, the email template should look similar to the one below.


To see how this would look in an email, and to make sure the links work properly, click the Preview tab on the left-hand side and either preview the email directly in Klaviyo or send it to yourself. An example of the former is shown below.


Additional Resources

Was this article helpful?
200 out of 369 found this helpful