Skip to main content
Solved

What is the right logic for displaying or not displaying a block of text with or without the first name?


Forum|alt.badge.img+3

Hello,

I'd like to personalize an email by displaying the first name when it's a known property.
And conversely, not to display it when it is not known.

Just to clarify, I don't want to display default words such as Friend or other to replace the first name because in French this doesn't work well in terms of the language.

So I tested the idea of creating two different text blocks and entered some logic to condition the display, as in the examples below: 

Text block with the first name :
Bonjour {{ first_name|default:''|capfirst }}, how are you?
Logic : person|lookup:'first_name'


Text block without the first name :
Hello, how are you?
Logic : not person|lookup:'first_name'

However, when I launch the preview, I get the following error message: 

"Message displayed without tags or variables
Fix invalid template tags or variables to preview the message with actual profiles and events."

Am I entering the right logic?

Is there a possible alternative? 
Perhaps with a single block of text and a formula that allows the first name to be displayed or not, and above all that doesn't leave a space between the word "Hello" and the comma?

Thank you in advance for your help.

Fabien
 

Best answer by Omar

Hi @Fabien and great question

I would recommend you to check out this explanation - 

You could do this inline (in html) to get this working.
Secondly here's another link to an article
https://developers.klaviyo.com/en/docs/use_conditionals_in_messages

 

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO

 

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

3 replies

Omar
Partner - Platinum
Forum|alt.badge.img+46
  • 2025 Champion
  • 494 replies
  • Answer
  • November 3, 2023

Hi @Fabien and great question

I would recommend you to check out this explanation - 

You could do this inline (in html) to get this working.
Secondly here's another link to an article
https://developers.klaviyo.com/en/docs/use_conditionals_in_messages

 

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO

 


Forum|alt.badge.img+3
  • Author
  • Contributor II
  • 3 replies
  • November 3, 2023

Hi @Omar,

Thank you so much for your reply!
I was able to get the variable rendering I wanted.


Omar
Partner - Platinum
Forum|alt.badge.img+46
  • 2025 Champion
  • 494 replies
  • November 3, 2023

Glad I could be of help! but you did all the hard work ;)

 

Omar Lovert // Polaris Growth // Klaviyo Master Platinum Partner

We help with e-commerce growth through CRO, Klaviyo and CVO


Reply