Placing conditions on dynamic content

  • 9 September 2023
  • 3 replies

Badge +3

Klaviyo dynamic content question: I am building a post-purchase upsell flow where when a customer buys a specific item, they enter the flow that suggest a few complementary items and offers a limited time discount code for adding onto their purchase. This flow is currently triggered upon the purchase of a specific product


In order to apply the content of this flow to a few items within that product’s collection, I'd like to be able to pull in an image and linked title of the product purchased. I am thinking of a dynamic content block like those used in abandoned cart and other post-purchase flows. 


However, I want this image block to pull in the item that customer purchased, but only within the collection that this flow is related to. I don’t want it to pull from items ordered at random. For example, the flow is targeted toward someone who purchased a father of the bride gift. If someone placed an order for a Father of the Bride cufflink AND a bridesmaid keychain, I only want the block to pull in the Father of the Bride item. 


Is it possible to filter for categories or collections like this within a dynamic product block, or should I be looking at designing the architecture of the flow differently to achieve my goal? Ie - creating branches based on product purchased and then cloning the emails and updating image across branches. 


Best answer by David To 11 September 2023, 18:17

View original

3 replies

Userlevel 7
Badge +60

Hey @AKwaterbody,

Congratulations on your first post in the Klaviyo Community!

You’re on the right track! Redesigning the architecture of the flow would certainly be one way to achieve your goal. Though, it would be the manual method. Using this method, you’ll need to include a series of condition/trigger splits to navigate users down specific branches - ultimately reaching the product the user purchased for other suggestions. 

A more effective method would be to use logic when creating your dynamic table blocks. Though, already having some conditional/trigger splits would still help streamline things. 

Since our email editor is based on jango, you’re certainly open to writing your own logic - such as if/else/elseif statements to help in either displaying or hiding certain products. For example, this has been done most commonly in abandoned cart flows to hide any trial products or shipping protection as detailed in the Community post below:

That said, the same strategy would apply to your situation. It would all simply be a matter of how you create your logic statement. If you need help on writing this, I would suggest watching through the tutorial our template specialist, @Anna McCarthy recorded in the post below. We also offer an expansive network of Klaviyo partners who offer more hands-on help which you can reach out to through our Klaviyo Partner Directory.

I hope this helps!


Badge +3

Thanks so much for the help! After reading through the tutorials and some trial and error I think I’ve finally figured out the proper use of if/else logic to achieve my goal. What a cool new tool to utilize!

Badge +3

Hi David,

I thought I had largely figured out how to make the conditional if/else statements work for our unique flow, but have run into one issue I can’t seem to crack.

Below is the statement I created to show specific text to customers in this ‘Placed Order’ triggered flow, based on the item they purchased:

{% if 'father of bride' in item.product.tags %}
<div>You've got Father of the Bride covered...let us help you cross a few more important people off your gifting list!</div>
{% elif 'father of groom' in item.product.tags %}
<div>You've got Father of the Groom covered...let us help you cross a few more important people off your gifting list!</div>
{% elif 'klaviyo wedding fathers' in item.product.tags and not 'father of groom' in item.product.tags and not 'father of bride' in item.product.tags %}
<div>You&rsquo;re on a gifting roll, let us help you cross a few more important people off your list!</div>
{% endif %}

This had been running smoothly through the test profiles I previewed. However my issue is that when someone orders both a ‘father of bride’ item and a ‘father of groom’ item, the text (and images which follow the same logic structure) are duplicating as pictured below - one for each item.



How do I prevent them from duplicating? Is there a statement I should be including that displays certain text/image when BOTH conditions are true? 


I’ve tried playing around with variations of the statement, including wrapping both ‘father of bride’ and ‘father of groom’ into the first if statement. I’ve also tried following the format of the example given in the if/else statement tutorial:


{% if "Dog" in person|lookup:"Pet Type" and not "Cat" in person|lookup:"Pet Type" %} dog.
{% elif "Cat" in person|lookup:"Pet Type" and not "Dog" in person|lookup:"Pet Type"  %} cat.
{% else %} pet. {% endif %}
That’s why we’ve created this super cool toy……

The results will be:
- If subscriber owns a dog, but not a cat: It will show “dog.”
- If subscriber owns a cat, but not a dog: It will show “cat.”
- If subscriber owns both dog and cat: It will show “pet.”
- If subscriber owns neither dog nor cat: It will show “pet.”


However, I keep getting error messages in preview mode. What would be the correct way to account for the instance when both conditions are true?

Thanks so much for your help!