---
title: "How to build dynamic blocks in a flow email"
description: "Learn how to use dynamic table blocks to add product and other event information to your metric-triggered flows. In this article, you'll learn how to create a dynamic block using the example of an abandoned cart reminder showing the products that were left behind."
canonical_url: "https://help.klaviyo.com/hc/en-us/articles/4408802597659"
markdown_url: "https://help.klaviyo.com/hc/en-us/articles/4408802597659.md"
locale: "en-us"
category: "Content"
section: "Use variable syntax and tags"
updated: "2026-10-30"
---

# How to build dynamic blocks in a flow email

## You will learn

Learn how to use dynamic table blocks to add product and other event information to your metric-triggered flows. In this article, you'll learn how to create a dynamic block using the example of an abandoned cart reminder showing the products that were left behind.

If you use one of Klaviyo’s prebuilt ecommerce integrations (e.g., Shopify, BigCommerce, Magento, or WooCommerce), you don’t need to build these blocks manually. Instead, [use the flow library](https://help.klaviyo.com/hc/en-us/articles/115002774932.md#h_01H9JGTZ8Q0PAF1FY71QDZBJ7M) to find pre-built, fully functional flow emails to use as templates. 

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.

🎬 [Watch video on Wistia](https://klaviyo.wistia.com/medias/m3tjywjv11)

## Before you begin

Before you can jump in, 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 data in emails, check out our [message personalization reference](https://help.klaviyo.com/hc/en-us/articles/4408802648731.md) as a first step. 

It will also be helpful to understand [data types in Klaviyo](https://help.klaviyo.com/hc/en-us/articles/115005237648.md), 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 cart items are stored as an array within a *Checkout Started* event. The *items* array contains one entry per item ordered, and each entry contains the details for that item (e.g., item name, image URL, quantity, size, color, etc.). 

## What types of flows can use dynamic table blocks? 

Dynamic table blocks contain information about one or more products that a customer interacted with in some way (e.g., purchased or left in their cart). These table blocks are useful for events that might contain different numbers of products, depending on a customer action. Dynamic table blocks are useful for flows triggered by these events: 

- Placed order (order confirmation flow)

- Started checkout (abandoned checkout flow) 

- Fulfilled order (shipping confirmation flow) 

- Cancelled order (cancellation confirmation) 

- Any other events that contain a list of one or more products



Use a static table block when the event provides a single product’s details without a product list to repeat over. Examples include:

- Added to cart (abandoned cart flow)

- Viewed product (browse abandonment flow) 



Learn how to create a [static table block for single-product events](#h_01J3JJSKQ3AD2SVKG4N26Z1R6C). 

## 1. Create your flow

Start by creating your flow:

1. Navigate to the **Flows** tab in Klaviyo.

2. Click **Create flow**. 

3. Click **Build your own**. 

4. Name your flow and click **Create flow**. 

5. Under *Select a trigger*, click **Your metrics**. 

6. Select which integration your trigger metric is sent from (e.g., Shopify).

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

8. Click **Save**, review your trigger, then click **Confirm and save**.

9. Drag and drop an *Email* action into the flow.



## 2. Add a dynamic table to your flow email

Next, add a dynamic table to your flow email:

1. Click the email block you added to your flow in the last section. 

2. Next to *Template*, click **Select template**. 

3. Choose a template to use as your base.

4. Drag a table block into your email.

5. Click **Styles >** **Dynamic** to convert the table into a dynamic block. You’ll see 2 fields appear: *Row collection* and *Row alias,* which you will fill in during steps 3 and 4.

6. Click back to the **Content** tab to adjust your column types.

7. Generally, an abandoned cart message shows images of the abandoned items on the left and details about the item on the right. Under **Cell selector**, select the left or right cell, then click **Text** or **Image** under **Cell content** to change the cell type.



![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/296b2aafbf8587130e21248cd8cd7a4a78f40ea2-714x890.png?auto=format)

## 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**.

2. Select a sample event that contains product data, then scroll through its preview data until you find an array that contains the information you need.

3. 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), and then your event will display within Klaviyo’s preview options.

4. In this Shopify 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* object containing more detail, including each item’s title, price, SKU, and image URL.


1. 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 2 variables within the first section of the array and copy them. In this example, copy the tags for *price* and *title*. Here are the 2 tags from this example: 

2. `{{ event.extra.line_items.0.price }}`

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



![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/34f757a4c2c6c31667b002671546f505b62d2017-940x622.png?auto=format)

![Two item subsections in event data](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/7b1c9e81bd852b3368847c66743078336c023246-804x1282.jpg?auto=format)

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

5. Use everything before `.0` as your **Row collection**. In this example, the value is `event.extra.line_items`. Close the preview, return to the table’s **Styles** tab, and enter that value in **Row collection** without curly brackets.



### Set fallback content (optional)

Fallback content will appear if there is no data in the row collection you select. This is only necessary when you build a table based on data that does not consistently appear within the trigger event. To add fallback content, toggle on the *Fallback content* option and add content (i.e., text or an image) to the field that appears. 

![The option to add fallback content](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/42bef87809ad5f1f93eb2552eae75859bf021aaa-698x848.png?auto=format)

## 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 repeats over a list of items in an abandoned cart, so *item* is a good alias to use. If your block repeats 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). 

![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/dfb6aa9723b8af7efa36d116c7fb78d973fd7321-714x1040.png?auto=format)

Once you’ve filled out the *Row collection* and *Row alias* fields, you’re ready to start building your table. 

## 5. Add dynamic product details

After the data source is set up, you can use tags to add 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. In the table’s **Content** tab, select the cell where you want the product details under **Cell selector**. For an image on the left and text on the right, select the right cell.

2. Double-click the text cell in your email, then 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 alias selected in the last step (e.g., *item*), keeping the surrounding brackets. For this example, `{{ event.extra.line_items.0.title  }}` becomes `{{ item.title }}`.




![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/555cf5690e0f2946ba70dda51500cd1001dbb63d-704x388.png?auto=format)

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 **Styles** 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 (e.g., *{{ event.extra.line_items.0.url }}* becomes *{{ item.url }}*). 

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. Click **Apply**.



**▸ Common product URL variables by integration**

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

**Magento 1**
Event variable: {{ event.extra.line_items.0.product.id }}
Final tag: {{ organization.url|trim_slash }}/catalog/product/view/id/{{ item.product.id }}

**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|trim_slash }}/products/{{ item.product.handle }}

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

### 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 %}`

## 6. Add an image

To insert a dynamic image, find the event variable for the image in the preview. Often, this variable is listed under `image`, `img`, or `src`, but it depends on your integration. In this example, it is `{{ event.extra.line_items.0.product.images.0.src }}`. Replace `event.extra.line_items.0` with `item`, as in step 5. Keep the `.0` after `images`: it selects the first image for each product.

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 **Select image**.

4. Select the **Dynamic image** tab.

5. Paste the customized image variable, `{{ item.product.images.0.src }}`, into the **Dynamic variable or dynamic URL** field.

6. Click **Save**.

7. Add the product URL variable from step five in the *Link address* field so the image is clickable.

8. Set **Max width** for the image, starting with 250–300 pixels and adjusting as needed.



## 7. Preview your email

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

![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/edd3b156e32c05697ad697a82acc27867f603824-2006x970.jpg?auto=format)

Click **Preview** and select a sample event with multiple products, if one is available. Check that each product’s image, details, and links match. If an image or other detail is missing, check the spelling and structure of your variables against the preview data, as well as your block’s **Styles** tab.

When you’re finished, close the preview and click **Exit**. Before turning on an abandoned cart flow, complete the timing and filter setup in [our abandoned cart flow guide](https://help.klaviyo.com/hc/en-us/articles/115002779411.md).

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

## Create a static table block for single-product events 

If an event provides a single product’s details without a product list, use a static table block. For these events, there is no need to set a **Row collection** or **Row alias**, and you can use unedited variables directly from your event data.

1. Navigate to the **Flows** tab in Klaviyo.

2. Click **Create flow**. 

3. Click **Build your own**. 

4. Name your flow and click **Create flow**. 

5. Under *Select a trigger*, click **Your metrics**. 

6. Select the integration that sends your metric, then choose a single-product metric, like **Viewed Product** or **Added to Cart**.

7. Click **Save**, review your trigger, then click **Confirm and save**.

8. Drag and drop an *Email* action into the flow.

9. Click the email block, then click **Select template** next to **Template**.

10. Select a template to use as your base.

11. Drag a table block into your email.

12. By default, the *Data* field is set to **Static** under *Styles*; do not change this setting.




![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/ebecf8b26513f050205db3eba881fca8e3861d61-706x644.png?auto=format)

13. Click **Preview** to see the variables available for your message. Click the image URL variable to copy it, then close the preview.




![Select an image URL variable](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/fc646076aa7e17f4c8202f3fc23ad9d4069eaec0-644x260.png?auto=format)

14. Using the *Cell selector* and *Cell content* fields, set the left cell to use the **Image** cell type.

15. Click **Select image**. 

16. Select **Dynamic image**. 

17. Paste the image URL variable you copied into the *Dynamic variable or dynamic URL* field. 

18. Click **Save**. 

19. Set the right cell to use the **Text** cell type. 

20. Click **Preview** to copy a variable you’d like to display (e.g., product title or product price). Close the preview, then double-click the text cell in your email and paste the variable. Repeat for any other details you want to add.



![Image](https://cdn.sanity.io/images/6ct6b26e/help-center-prod/0529213ab676b9d9410167f109c0a01c336040dd-696x580.png?auto=format)

21. Add additional blocks, like a CTA button to return to their cart, and style the email as desired.

22. Click **Preview** and check the product image, text, and links using a sample event for your flow’s trigger.

23. When you’re finished, close the preview and click **Exit**.

## Additional resources

- [How to create an abandoned cart flow](https://help.klaviyo.com/hc/en-us/articles/115002779411.md)
  Learn how to set up an abandoned cart flow in Klaviyo in order to increase your ecommerce revenue and personalize communication to your customers. 
- [Message personalization reference](https://help.klaviyo.com/hc/en-us/articles/4408802648731.md)
  Learn how to use Klaviyo’s personalization variables, or tags, to customize the experience for your customers.
- [How to display products vertically in emails](https://help.klaviyo.com/hc/en-us/articles/19462923466651.md)
  Learn how to display products in your abandoned cart and order confirmation flows vertically (i.e., with an image above product information, rather than beside). 
- [Apply programming logic concepts to build more personalized messages](https://academy.klaviyo.com/apply-programming-logic-concepts-to-build-more-personalized-messages/1857035)
