Skip to main content
Contributor II
November 3, 2023
Solved

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

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
 

    This topic has been closed for replies.
    Omar
    OmarAnswer
    2025 Champion
    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

     

    Helping E-commerce brands maximize Lifetime Value & Profits with Klaviyo, CRO & CVO - Get your free Audit - https://link.polarisgrowth.com/free-audit

    3 replies

    Omar
    Partner - Platinum
    OmarAnswer
    2025 Champion
    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

     

    Helping E-commerce brands maximize Lifetime Value & Profits with Klaviyo, CRO & CVO - Get your free Audit - https://link.polarisgrowth.com/free-audit
    FabienAuthor
    Contributor II
    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
    2025 Champion
    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

    Helping E-commerce brands maximize Lifetime Value & Profits with Klaviyo, CRO & CVO - Get your free Audit - https://link.polarisgrowth.com/free-audit