How to use event variables to personalize flows

read
Last updated at:

You will learn

Learn what dynamic event data is, when to use it, where to find it, and how to include it in your flow messages. Learn about the different actions your customers take, and how you can use that data for creating personalized messaging flows in Klaviyo. 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.

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.

Common examples of metric-triggered flows include:

How to find event variables

SMS

  1. In the flow builder, click the SMS or MMS you want to add an event variable to.
  2. Next, click Configure Content.
    Inside an SMS or MMS event variable in a flow, below the section for Content a  button for Configure Content so you can add an event variable
  3. Click Configure Content to view where you can add text, emojis, static or dynamic images, and GIFs to your message. Here, you can also insert profile properties and event variables.SMS Preview for SWAK Lip Care with content message options on the left hand side and visual preview on the right side
  4. 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. 
  5. 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.When inside an SMS or MMS, navigate to the Previewing tab in the upper right-hand side and hovering on the info icon to see the View Details action
  6. This dropdown contains information on 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.
    Inside the Previewing tab in the upper-right-hand side, click on the info icon to expose the Event Properties details below in the modal

Emails

To add event variables in a flow email: 

  1. Open the email in the flow editor. 
  2. Click Edit Content.
  3. Click Preview and Test.
  4. Click on a property name from the Event Properties menu to copy it. 
    A user copies an event variable in Klaviyo
  5. Paste the variable into your flow email.
This preview window will show all of the data available for that particular event metric. List entries are numbered starting at 0. 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.

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.

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 a Started 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.

Event variable arrays (email only)

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" in the middle or at the end, 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.

The data from a basic placed order event in Klaviyo

Iterating over dynamic event variables (email only)

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?
488 out of 873 found this helpful