Solved

When & how to loop over event data

  • 6 September 2023
  • 2 replies
  • 191 views

Badge +2

I am trying to return event data that could be anywhere from 1 to 5 items, I want each one to populate in a bulleted list but I only want the bullet to show up if there is an associated event (ie. if theres only 1 item for someone, I don’t want 4 blank bullet points under that 1 item). Does looping achieve this? If so, what is the code I would use for that?

Here is an example of the list I am trying to populate that has variable number of values returned back on the person. 

 

icon

Best answer by JessFosnough 6 September 2023, 20:40

View original

2 replies

Userlevel 5
Badge +17

Hi @MZeeb,

If you put your bullet point inside a dynamic table and loop, then it should only show up if there is event data. For example, we have an Abandoned checkout email that loops over with the items in the customer’s cart. Our table looks like this:

 

 

We don’t actually have bullets in our email, but I tested it by putting bullets before the item number and price, and it seemed to work. Our table also has an event slice, so that it only shows 5 items in their cart. When setting this up, I found this article on template tags and this one on building dynamic blocks in a flow to be very hepful.

Best of luck!

Badge +2

You can also do this kind of thing dynamically using AMP and interactive HTML like Zaymo does. That way the event data stays up to date with your store as well (out of stock, prices, images, etc)

Reply