How to build dynamic blocks in a flow email (new editor)

read
Last updated at:

You will learn

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

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, then convert the template to use the new editor. 

These steps refer to Klaviyo's new template editor. If you are working in a classic editor template, create a new template to use the new editor.

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.

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 begin

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 or profile 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 1: create your flow

  1. Navigate to the Flows tab in Klaviyo.
  2. Click Create Flow
  3. Click Create From Scratch
  4. Name your flow and click Create Flow
  5. Under Trigger setup, click Metric
  6. Choose the event that should trigger your flow. In this example, we'll use the Checkout Started event. This ensures that we have access to the event data necessary to construct an abandoned cart block.
  7. Click Done
  8. Drag and drop an Email action into the flow.

Step 2: add a dynamic table

  1. Click the email block you added to your flow in the last section. 
  2. Click Configure Content
  3. Choose Drag and Drop
  4. Choose a template to use as your base.
  5. Drag a table block into your email.
  6. Click Table Settings > 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.
  7. 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 3: identify your row collection

In this step, you'll add the name of the array you plan to iterate over to the Row collection field. To find the name of your array:

  1. Click Preview and test.
  2. Click Event
  3. Select the event that triggers this flow (e.g., Checkout Started).
  4. 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 2 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 }}

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

  6. 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 4: 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 5: 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:

  1. Navigate to one of the table's 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.
  2. Paste in the full event variable from the preview modal (e.g., {{ event.extra.line_items.0.title }}).
  3. 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
  4. 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
Common product URL variables by integration

BigCommerce
Event variable: {{ event.extra.items.0.product.url }}
Final tag: {{ organization.url }}{{ item.product.url }}

Magento 1
Event variable: {{ event.extra.line_items.0.product.key }}
Final tag: {{ organization.url }}{{ item.product.key }}

Magento 2
Event variable: {{ event.Items.0.Product.FullURL }}
Final tag: {{ item.Product.FullURL }}

Shopify
Event variable: {{ event.extra.line_items.0.product.handle }}
Final tag: {{ organization.url }}products/{{ item.product.handle }}

WooCommerce
Event variable: {{ event.extra.Items.0.URL }}
Final tag: {{ item.URL }}     

 

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 6: 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.

  1. Once you have this variable, head to the column where you want to display the image (the left column, in this case).
  2. Click Image under Cell content if it’s currently set to Text.
  3. Click Add Dynamic Image / Browse Image.
  4. In the Dynamic Image tab, paste your image variable into the Dynamic variable or dynamic URL field.
    add_image.gif
  5. Input the customized image event variable, {{ item.product.images.0.src }}.
  6. Click Save.
  7. Add the product URL variable from step five in the Link address field so the image is clickable.
  8. Set a max width for the image, starting with 250-300 and adjusting as needed.
  9. 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 7: 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?
92 out of 216 found this helpful