Skip to main content
Solved

Logic based HTML email


Sumit_2809
Problem Solver I
Forum|alt.badge.img+3

Is there is a way to add Conditional or Logic on Custom HTML emailers ? or maybe to do both HTML and drag and drop ?

I am facing an issue as I have pre-defined HTML email template but i don't want to show certain products to certain to some people is there is way I can add logic in HTML code itself?

Best answer by Taylor Tarpley

Hi there @Sumit_2809

 

Welcome to the Community! 

 

Yes, you can definitely do this within an HTML template. The show/hide logic is just a user-friendly rendering of conditional If-Else statements in Django.


 
You can use this same logic to insert into your HTML template based on the content you would like to show or hide. To conditionally show content in your email, wrap this portion of the email an initial {% if insert_your_condition %} as well as the closing {% endif %} tag. You can reference the same profile/event variables you would use in the Display Options within Klaviyo's drag-and-drop editor.


 
I’d recommend checking out these helpful resources on conditional statements below to gain more insight!
Klaviyo Developers Portal - Use conditionals in messages
How to show or hide template blocks and sections based on dynamic variables
Template tags and variable syntax reference
 
It should be noted that since you’re using a custom HTML template, Klaviyo can’t assist with designing or building out this templates, however, I’d reach out to your developer or a Klaviyo partner to help build this out for you if you need assistance. 

 

Hope his helps!

-Taylor 

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

4 replies

Taylor Tarpley
Community Manager
Forum|alt.badge.img+60
  • Community Manager
  • 2148 replies
  • Answer
  • August 21, 2023

Hi there @Sumit_2809

 

Welcome to the Community! 

 

Yes, you can definitely do this within an HTML template. The show/hide logic is just a user-friendly rendering of conditional If-Else statements in Django.


 
You can use this same logic to insert into your HTML template based on the content you would like to show or hide. To conditionally show content in your email, wrap this portion of the email an initial {% if insert_your_condition %} as well as the closing {% endif %} tag. You can reference the same profile/event variables you would use in the Display Options within Klaviyo's drag-and-drop editor.


 
I’d recommend checking out these helpful resources on conditional statements below to gain more insight!
Klaviyo Developers Portal - Use conditionals in messages
How to show or hide template blocks and sections based on dynamic variables
Template tags and variable syntax reference
 
It should be noted that since you’re using a custom HTML template, Klaviyo can’t assist with designing or building out this templates, however, I’d reach out to your developer or a Klaviyo partner to help build this out for you if you need assistance. 

 

Hope his helps!

-Taylor 


retention
Partner - Platinum
Forum|alt.badge.img+62
  • 2025 Champion
  • 920 replies
  • August 21, 2023

Just to add to @Taylor Tarpley answer here, you can also use the Show/Hide feature for the Block or Section in the Drag and Drop version.  You can learn more about it here:

 

Joseph Hsieh // retentioncommerce.com // twitter: @retenion 


Sumit_2809
Problem Solver I
Forum|alt.badge.img+3
  • Author
  • Problem Solver I
  • 5 replies
  • August 22, 2023
Sumit_2809 wrote:

Is there is a way to add Conditional or Logic on Custom HTML emailers ? or maybe to do both HTML and drag and drop ?

I am facing an issue as I have pre-defined HTML email template but i don't want to show certain products to certain to some people is there is way I can add logic in HTML code itself?

Thank you so much for your help Taylor...Sure I will reach out to you if  required!😀


Sumit_2809
Problem Solver I
Forum|alt.badge.img+3
  • Author
  • Problem Solver I
  • 5 replies
  • August 22, 2023

Thank you Guys!