Skip to main content
Solved

Dynamic Block Based on Cart


Forum|alt.badge.img+2

I’m currently updating our abandoned cart flow and looking to personalize it further. 

Is it possible to show specific testimonials based on what’s in their cart? For example, if customer added shorts to their cart it would only short testimonials for our shorts. If customer adds shorts and jersey, they would receive a testimonial for both products. 

 

Best answer by alex.hong

Hi there @cyclist-jz,

Thanks for sharing to the Community.

It sounds like you would want to use our Show/Hide feature for blocks based on certain variables. In this case, the variable would have to look for an item in the cart and display only if item X is found. You can find all of the details on how to show/hide blocks based on event data here.
I recommend reading through that guide as well as the other sections. Some of the other sections have examples of different formatting that can be used. Essentially you are able to set a block to only show if "XYZ" is in "event.items". Of course you would have to build out the actual names and event variables, but that is the general structure. You will find that you can set this to be an exact match or a contains match. 

Often times, customers have found that platforms like Shopify does not provide Klaviyo with a way to dynamically add customer reviews to an email.  What some of our customers choose to do is to add Text Blocks to their emails and to manually copy-and-paste reviews to their emails.  These reviews are static and require our customers to manually update these responses from time to time.

Alternatively, some of our other customers choose to integrate a Review platform with their Klaviyo account.  You can see a number of integrations we offer for this type of service here.  You can use any of these integrations to dynamically add reviews to your emails.

 

Hope this helped,

Alex

 

 

View original
Did this topic or the replies in the thread help you find an answer to your question?

9 replies

alex.hong
Forum|alt.badge.img+58
  • Klaviyo Alum
  • 1552 replies
  • Answer
  • May 10, 2022

Hi there @cyclist-jz,

Thanks for sharing to the Community.

It sounds like you would want to use our Show/Hide feature for blocks based on certain variables. In this case, the variable would have to look for an item in the cart and display only if item X is found. You can find all of the details on how to show/hide blocks based on event data here.
I recommend reading through that guide as well as the other sections. Some of the other sections have examples of different formatting that can be used. Essentially you are able to set a block to only show if "XYZ" is in "event.items". Of course you would have to build out the actual names and event variables, but that is the general structure. You will find that you can set this to be an exact match or a contains match. 

Often times, customers have found that platforms like Shopify does not provide Klaviyo with a way to dynamically add customer reviews to an email.  What some of our customers choose to do is to add Text Blocks to their emails and to manually copy-and-paste reviews to their emails.  These reviews are static and require our customers to manually update these responses from time to time.

Alternatively, some of our other customers choose to integrate a Review platform with their Klaviyo account.  You can see a number of integrations we offer for this type of service here.  You can use any of these integrations to dynamically add reviews to your emails.

 

Hope this helped,

Alex

 

 


Forum|alt.badge.img+2
  • Author
  • Contributor II
  • 3 replies
  • May 11, 2022

Thank you Alex. I will give this a try and report back as to whether this worked or not. 


Forum|alt.badge.img+2
  • Contributor I
  • 5 replies
  • August 25, 2023

Hello,

 

I am looking at the exact same thing and can’t find an answer. The link shared  by Alex does not work anymore.

Also, i’m not a developper so if someone has the formula written it would be even better (else it’s fine i’ll sort it out)

 

Thank you


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • August 25, 2023

Hey @janz,

Thanks for letting us know those links don’t work. I’ve gone ahead and updated them. 

Since you’re creating a formula based on the data pertaining to your own account, this really would be something custom. In addition to the How to show or hide template blocks and sections based on dynamic variables Help Center article @alex.hong previously shared, I would also suggest taking a look at our Conditional logic reference for templates article. This gives you a great idea on how to format your conditional logic to achieve your end goal. 

Our template specialist, @Anna McCarthy also has a wonderful tutorial video on guiding users on how to write their own conditional logic formal. I’ve linked their post below:

David


Forum|alt.badge.img+2
  • Contributor I
  • 5 replies
  • August 30, 2023

Hello,

 

Thank you, i did some work using your links and i came up with something that just partially work.

If I use the following event.extra.line_items.0.product.id|default:'' == 1111111111

 

the only issue is that this only checks the first item in the cart. I would like the formula to check any product in the cart, else it would make it too complex since I would need to think of all the possibilities (if products with ID 111111 is on the first position, or second one, or third one, etc. for every products).

 

Do you have any idea? Thanks a lot

 

 


Forum|alt.badge.img+2
  • Contributor I
  • 5 replies
  • August 31, 2023

David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • August 31, 2023

Hey @janz,

Looks like you’re logic statement is only evaluating for product.id == 1111111111 in the 0 position/first position of the array. As noted by the 0 - event.extra.line_items.0.product.id|default:.

Instead, I would recommend evaluating for product.id == 1111111111 in your entire array. This way, you wouldn’t have to manually iterate through all the array positions/row items. 

David


Forum|alt.badge.img+2
  • Contributor I
  • 5 replies
  • September 4, 2023

Hi @David To 

 

Thank you for getting back to me. I tried everything and nothing works, how can i evaluate in the entire array?

 


David To
Klaviyo Employee
Forum|alt.badge.img+60
  • Klaviyo Employee
  • 2456 replies
  • September 5, 2023

Hey @janz,

It’s really going to depend entirely on how your data is being passed. If you haven’t already, I would suggest reaching out to our support colleagues who may be able to help take a look. 

Alternatively, if you need more hands-on help, I would advise reaching out some of our wonderful Klaviyo Partners through our Partner Directory who specialize in email designs. 

David