About Using Event Variables to Personalize Flows

read
Last updated at:

Overview

You can create personalized flow emails and SMS by using dynamic event data. For instance, you could use event data in an abandoned cart flow message 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 messages.

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 messages.

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 or SMS. 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.

image21.png

Common examples of metric-triggered flows include:

How to Find Event Variables

SMS

Choose the SMS or MMS you want to add an event variable to. Next, click Configure Content.

  2020-12-29_15-07-10.png

Clicking Configure Content will take you to where you can add text, emojis, images, and GIFs to your message. Here, you can also insert profile properties and event variables.

2020-12-29_15-27-23.png

You can find event variables on the right-hand side of the screen in the Previewing tab. This tab shows the 10 most recent events that you can navigate between; e.g., for a post-purchase flow, the 10 most recent Placed Order events will show here.  

More importantly for this article, the Previewing tab will also show all the associated event variables. To view the variables, click the View details button in the upper right-hand corner of the tab.

image4.png

This dropdown will contain information all of the variables for that event. By clicking any line item, you can automatically copy it to your clipboard, making it easy to add event variables into your message. 

image3.png 

Emails

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.

image24.png

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.

image10.gif

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 {{ event.extra.line_items.0.product.name }} 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.

image20.gif

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 }}.

image18.png

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.

image14.png

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

2020-01-06_12-23-14.png

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. 

BigCommerce
Product Name/Title {{ event.extra.line_items.0.product.name }}
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

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

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

Product URL

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

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

Image

{{ 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 }}

Quantity

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

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

Total

{{ event.extra.base_grand_total }}

{{ event.extra.base_grand_total }}

Shopify
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 }}
WooCommerce*
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.

Iterating over Dynamic Event Variables in Emails

There are two different ways of iterating over these or other event variable arrays in emails:

  1. The Block Repeat Feature
    This 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.
  2. A Dynamic Table
    This helps you create a more complex block that loops over all entries for a single variable array. 

Note that while you can add dynamic event variables to text messages, you cannot iterated over multiple ones. 

Additional Resources

x
Was this article helpful?
235 out of 428 found this helpful