Solved

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

  • 3 November 2023
  • 3 replies
  • 121 views

Badge +2

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
 

icon

Best answer by Omar 3 November 2023, 11:50

View original

3 replies

Userlevel 7
Badge +44

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

 

Badge +2

Hi @Omar,

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

Userlevel 7
Badge +44

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