How to Build Dynamic Blocks in a Flow Email (new editor)

read
Last updated at:

Overview

Learn how to use dynamic table blocks to add product and other event information to your metric-triggered flows.

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.

Within a metric-triggered flow, you can personalize the content of your emails based on the event that triggers the flow. For example, if someone starts a checkout, you can include product images and prices within an abandoned cart email to encourage recipients to return to their cart and finish their purchase. The dynamic table block will automatically repeat with the information specified for each item in the cart.

If you use one of Klaviyo’s prebuilt ecommerce integrations (like Shopify, BigCommerce, Magento, or WooCommerce), you don’t need to build these blocks manually. Instead, use the Flow Library to find pre-built, fully functional flow emails to use as templates. 

In this article, we’re going to build out a dynamic block in an abandoned cart email that shows the products they left behind. 

Before You Start

Before you can jump in, you’ll want to make sure that you have event data to use. Navigate to Analytics > Metrics to make sure the event exists in Klaviyo.

If you are unfamiliar with using event, profile, or catalog variables in emails, check out our Guide to Template Tags and Variable Syntax as a first step. 

It will also be helpful to understand data types in Klaviyo, particularly lists (i.e., arrays). An array is a way to store multiple pieces of data that are structured the same way. For example, a customer’s purchased items are stored as an array within a Placed Order event. The items array contains one entry per item ordered, and each entry contains the details for one item (e.g., item name, image URL, quantity, size, color, etc.). 

Step One: Create Your Flow

First, create a flow that is triggered by a metric (or event). In this example, because we are building an abandoned cart block, we need our flow to be triggered by the Started Checkout event. This ensures that we have access to the event data necessary to construct an abandoned cart block.

From there, you can drag and drop an email into the flow and customize it.

Step Two: Add a Dynamic Table

Drag a table block into your email and click Table Settings. Click Dynamic to convert the table into a dynamic block. You’ll see two fields appear: Row Collection and Row alias; we’ll complete those fields in the next steps. 

Click back to the Content tab to adjust your column types. Generally, an abandoned cart message will show images of the abandoned items on the left and details about the item on the right. Click on the left or right row selector, then click Text or Image to change the cell type. 

create_dynamic_block.gif

Step Three: Identify Your Row Collection

Add the name of the array you plan to iterate over to the Row collection field.

To find the name of your array, click Preview and test. Click Event, then select the event that triggers this flow (e.g., Started Checkout). 

Scroll through the preview data for your event until you find an array that contains the information you need. You can use the arrow icons on the left of the data to collapse sections you don’t need and make it easier to navigate. 

If no one has completed the flow’s trigger action yet, there will be no preview data available for the flow. You can navigate to your site to take the action (e.g., add items to your cart and start a checkout without completing it), and then your event will display within Klaviyo’s preview options. 

navigate_event_data.gif

In this example, there are two arrays that store item information: 

  • Items
    A top-level array containing a simple list of each item’s name
  • line_items,
    An array nested within the extra array containing more detail, including each item’s title, price, SKU, and image URL

Two_items_subsections_in_event_data.jpg

You’ll want to use the more detailed array, line_items, since it contains the detailed information needed to display in the repeating table block. To find the appropriate variable to set in the Row collection field, select two variables within the first section of the array and copy them. In this example, copy the variables for variant_price and title. Here are the two variables from this example: 

{{ event.extra.line_items.0.variant_price }}

{{ event.extra.line_items.0.title }}

Ignore the curly brackets and look at the variables within them. Note that the beginning of both variables are the same: event.extra.line_items.0

Use everything up to (but excluding) the dot and the number at the end of this portion of the variable as your Row collection. In this example, the appropriate setting for the Row collection field is event.extra.line_items.

Step Four: Choose a Row Alias

Your row alias can be any text you’d like to use (with no special characters or spaces). You’ll use this alias within your dynamic table block to identify variables that should be pulled from the array you selected above. It’s helpful to choose a simple but descriptive alias, so it’s easy to remember. 

In this example, the dynamic table block is repeating over a list of items in an abandoned cart, so item is a good alias to use. If your block is repeating over a list of blog posts, then you could use post as your alias.

You can use any alias you’d like; just make sure to consistently use that alias in variables from your array (as outlined in the following steps). 

table_settings.jpg

Once you’ve filled out the Row Collection and Row Alias fields, you’re ready to start building your table. 

Step Five: Add Dynamic Product Details

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, along with other details like a price and link to purchase.

To input the product title in your block, navigate to one of the columns. If you want an image in the first column and the text in the second, click on the column selector on the right of the block’s Content section.

Paste in the full event variable from the preview modal (e.g., {{ event.extra.line_items.0.title }}). Next, replace the row collection within the variable (i.e., the text you used for the Row collection) and the following dot and number with the Row Alias, keeping the surrounding brackets. For this example, {{ event.extra.line_items.0.title }} becomes {{ item.title }}, since item is the alias.

table_with_dynamic_text.jpg

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, as well as your settings in the Table Settings tab, to ensure there are no errors.

Repeat the same steps to add in additional item details. 

Hyperlinking a Product Title

To add a hyperlink to the product title: 

  1. Find the product URL variable in your event details
  2. Replace the row collection and number with your row alias, as with the variable above 
  3. Highlight the full variable for the item’s title (e.g., {{ item.title }}
  4. Click the link icon and paste your URL variable into the URL field

hyperlink_product_title.gif

Considerations for Currency Variables

If your item price is passed as a number in your event details (with no currency symbol), use the currency_format tag to apply currency formatting. To apply this tag, replace variable_name in the code below with the full price variable, excluding curly brackets from the original variable: 

{% currency_format variable_name %}

So, your final variable might look like this: 

{% currency_format item.price %}

Step Six: Add an Image

To insert a dynamic image, you need to find the event variable for the image in the preview modal. 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.0.src }}. Apply the same adjustments to this variable as outlined in step five (replacing event.extra.line_items.0 with item). This is an event variable array within 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 (the left column, in this case). Click Image under Cell content if it’s currently set to Text. Click Add Dynamic Image / Browse Image. In the Dynamic Image tab, paste your image variable into the Dynamic variable or dynamic URL field. 

add_image.gif

Input the customized image event variable, {{ item.product.images.0.src }}, and click Save. Add the product URL variable from step five in the Link address field so the image is clickable. Then set a max width for the image, starting with 250-300 and adjusting as needed. 

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

Step Seven: Preview Your Email

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

Dynamic_block_preview.jpg

To see how this would look with dynamic content, and to make sure the links work properly, click Preview and test. If there are any errors, check the spelling and structure of your variables, as well as your Table Settings tab. 

You can use these same concepts to build out additional dynamic blocks for flows triggered based on different metrics.

Summary

As a recap, follow these steps to build a dynamic table block in your flow email:

  1. Create a metric-triggered flow
  2. Add a table block and set it to Dynamic
  3. Use the preview modal to identify your Row collection 
  4. Choose a Row alias 
  5. Add dynamic product details by adjusting the variables
  6. Add a dynamic image
  7. Preview

Additional Resources



x
Was this article helpful?
4 out of 9 found this helpful