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

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

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.

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 }}
Two item subsections in event data
Two item subsections in event data
  1. 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.
  2. 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
The option to add fallback content

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

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

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.

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.
  1. 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
Select an image URL variable
  1. Using the Cell selector and Cell content fields, set the left cell to use the Image cell type.
  2. Click Select image.
  3. Select Dynamic image.
  4. Paste the image URL variable you copied into the Dynamic variable or dynamic URL field.
  5. Click Save.
  6. Set the right cell to use the Text cell type.
  7. 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.
  1. Add additional blocks, like a CTA button to return to their cart, and style the email as desired.
  2. Click Preview and check the product image, text, and links using a sample event for your flow’s trigger.
  3. When you’re finished, close the preview and click Exit.

Additional resources

Was this article helpful?
Use this form only for article feedback. Learn how to contact support.

Explore more from Klaviyo

Community
Connect with peers, partners, and Klaviyo experts to find inspiration, share insights, and get answers to all of your questions.
Partners
Hire a Klaviyo-certified expert to help you with a specific task, or for ongoing marketing management.
Support

Access support through your account.

Email support (free trial and paid accounts) Available 24/7

Chat/virtual assistance
Availability varies by location and plan type