Overview

Event variables can be used in Klaviyo's email editor to create dynamic blocks of content. Its advanced flexibility lets you use these variables with simple copy-pasting, or to manually build custom templates for those savvy with HTML and CSS.

In this guide, you'll find an explanation of how event variables work, some best practices as well as code examples you can copy and paste into your own templates.

Table of Contents

1. Klaviyo Event Variables

1.1. Event Variables Included in Octane AI Events

1.2. Previewing Emails (and Locating Event Variables)

1.3. Klaviyo's New vs. Classic Editor

2. Using Event Variables Dynamically

2.1. Sample of a Dynamic Code Block (Advanced)

This feature is currently available on Octane AI's Pioneer & Enterprise plans. To learn more, contact our support team.


1. Klaviyo Event Variables

Event variables are how Klaviyo stores certain data and metrics from third party integrations like Octane AI. Not all integrations with Klaviyo have event variables, but the ones that do including Octane AI all have slight variations in formatting.

Here's what the most basic implementation of an event variable looks like:

The highlighted text represents different parts of the 'quiz completed' event data:

  • Blue is the variable array.

  • Yellow is the array number.

  • Red is the specific variable.

The variable array, events.products_all looks at the product recommendation data for this specific event. The number 0 refers to the specific product listed in the event, where 0 = the 1st product, 1 = the 2nd product, 2 = the 3rd product and so on.

product_title is the specific variable, which in this case is the actual title of the product that the code references. In this case, because the array is 0, the title will be the first product on the list "WE SKINCARE Pure-Nature Toner".

By using a different variable, you can change the data that you're referencing. For example, here's the example above depicted as the event variables that were used to dynamically represent the product block.

[Image Block]
{{ event.products_all.0.image }}

[Text Block]
{{ event.products_all.0.title }}
{{ event.products_all.0.price_formatted }}

[Button]
{{ event.products_all.0.link }}

If you wanted this block to show the 2nd product in someone's recommendation instead, you would change the 0 to a 1 instead.

There are more advanced ways to use event variables but with this example alone, you could build a flow that emails someone their personal results whenever they finish the quiz after submitting their email.

1.1. Event Variables Included in Octane AI Events

These are all of the specific event variables that Octane AI can send with a 'quiz completed' event in Klaviyo.

Quiz Completed

Data

Event variable

Title

title

ID

id

Store URL

link

Image

image

Price

price_formatted

Description

description

Tags

tags

Type

type

1.2. Previewing Emails (and Locating Event Variables)

You can build dynamic emails with event variables while editing an email template (and we highly recommend doing so), but you won't be able to preview what the events will look like to a user in the template editor.

Instead, the best way to preview what your email will look like to someone who has actually completed a quiz is in a flow. This is because the preview needs an actual event to sample data from in the preview, which we can set up in flow by creating a trigger based on Octane AI's 'quiz completed' event.

While previewing, Klaviyo will provide the basic code reference to a particular event variable for quick reference.

1.3. Klaviyo's New vs. Classic Editor

Klaviyo has two different editors you can choose when creating an email template. Your choice here is important, since templates cannot be transferred between templates.

Event variables can be used in both editors simply by adding the variable in its correct format into the type of content you're creating with the event variable (image, text, hyperlink and so on).

One advantage of the classic editor is its large library of pre-designed templates you can start with. However, the new editor allows you to save individual content blocks, letting you set up a single block and add it to any email with Klaviyo's drag-and-drop editor rather than having to save and copy entire email templates.

Using the new editor may be a stronger choice for compatibility with future Klaviyo updates.

Back to top.


2. Using Event Variables in Dynamic Blocks

If you add event variables to an email using the basic shortcode format (e.g. {{ event.products_all.0.image }}), the content displayed will be unique for each customer's quiz result, but because the basic form of the code can only reference one product entry at a time (represented by the array, 0).

This means you have to manually add content blocks for each product entry that someone is recommended. If your results page recommended 3 products for example, you would need to create three sets of content blocks in your Klaviyo email template.

However, instead of using multiple blocks to add products to your email, you can use a single dynamic block instead.

The example below is a dynamic table, which can be used to format a single product entry that's repeated for every product the subscriber received in their quiz results.

Here are the types of dynamic blocks you can create:

  • Dynamic tables: create a single-row table entry using event variables that will repeat for each product the selected variable array.

  • Block repeating: set a single block to repeat based on each item in a variable array.

  • HTML / CSS: use HTML and CSS to create a custom block.

Dynamic tables and block repeating use dynamic variables which are slight variations on normal event variables.

When should I use a dynamic block instead of manually building blocks?

Depending on how many products you recommend, dynamic content blocks may not be the best option for your template. Dynamic blocks will show however many products a customer was recommended when they completed your quiz.

So if your quiz has the potential to recommend a large amount of products you may want to consider whether that's compatible with the template you're building.

Manually-built blocks

  • Can control the exact format of the email.

  • Most straightforward.

    • You can build blocks with nothing but the event variable and Klaviyo's drag-and-drop editors.

  • Highly flexible in Klaviyo's email editor.

Dynamic blocks

  • Great for large recommendations or recommendations where the number of final products in the result can vary.

  • Only one block needs to be made for the template.

2.1. Sample of a Dynamic Code Block (Advanced)

Here's a simple example of a dynamic block created from scratch using event variables and code:

{% for products in event.products_all|slice:':10' %}
<p style="text-align: center;"><a href="{{ products.link }}" target="_blank"><img alt="" src="{{ products.image }}" style="width: 150px; height: 150px;" /></a>‚Äč</p>

<h2 style="text-align: center;"><a href="{{ products.link }}" target="_blank">{{ products.title }}</a></h2>

<h4 style="text-align: center;">${{ products|lookup:'price_formatted' }}</h4>

We only recommend building emails with HTML and CSS for technically savvy users, or those with access to a developer. The code above only contains basic styling, but is an example of how code can be used to create a dynamic block from scratch.

Back to top.


Have any questions? Send an email to [email protected] or use the support icon to chat with our team.

Did this answer your question?