Contact Property If Statement in Email

SOLVE
New Contributor

Hello Everyone,

I am attempting to create an email that shows content based on contact properties, but for some reason the if statements don't seem to work. If I put in the HUBL for the contact property it will show up, but the if statement will not.

Here is the code from the email template:

{{contact.do_you_have_small_children_or_pets_}}
{% if contact.do_you_have_small_children_or_pets_ == 'Yes' %}
<p>Text for small children and pets.</p>
{% endif %}
{{contact.are_the_windows_in_a_hard_to_reach_spot_}}
{% if contact.are_the_windows_in_a_hard_to_reach_spot_ == 'Yes' %}
<p>Text for hard to reach windows.</p>
{% endif %}

I know the contact properties are correct and are loading because I get the double 'Yes' in the email if I send it as if it is going to the user with the 2 Yes properties. I am thinking there is a problem with the if statement or I am not reading the contact property field properly. Sorry I usually work with PHP.

If anyone has any ideas I would greatly appreciate it.

2 Accepted solutions

Accepted Solutions
Regular Advisor

@fcomstoc,

if statements with contact properties don't work in email templates.

 

If you conditionals are blocks of text or paragraphs, you can use multiple rich text modules and smart content in your email template to achieve similar results.

 

Example structure

Main Email body module (1st paragraph, static text)

Rich Text module, Smart Content (2nd paragraph, conditional 1)

Rich Text (3rd paragraph, static text)

Rich Text  module, Smart Content (4rd paragraph, conditional 2)

Rich Text (closing and signature, static text)

 

It's not the most user friendly approach, but has worked for me several times.

Highlighted
Regular Contributor

Was about to write the same but @ndwilliams3 was a little quicker than me Smiley Happy

 

Maybe some additional Infos about how to create Smart Content in emails:

 

1. Segment your different groups of contacts in different lists (f.e. List1: property 1 = yes, List2: property 2 = yes) 

 

Bildschirmfoto 2016-12-02 um 13.50.18.png

2. Rich-Text-Modules in emails can be made smart (based on lists or lifecycle-stages):

 

Bildschirmfoto 2016-12-02 um 13.52.33.png

 

3. Choose your Lists and create a different email copy for each group of contacts.

 

Bildschirmfoto 2016-12-02 um 13.52.56.png

Bildschirmfoto 2016-12-02 um 13.57.25.png

 

Best regards

Thomas

5 Replies 5
Regular Advisor

@fcomstoc,

if statements with contact properties don't work in email templates.

 

If you conditionals are blocks of text or paragraphs, you can use multiple rich text modules and smart content in your email template to achieve similar results.

 

Example structure

Main Email body module (1st paragraph, static text)

Rich Text module, Smart Content (2nd paragraph, conditional 1)

Rich Text (3rd paragraph, static text)

Rich Text  module, Smart Content (4rd paragraph, conditional 2)

Rich Text (closing and signature, static text)

 

It's not the most user friendly approach, but has worked for me several times.

Occasional Contributor

Man Mad

 

You can make lists if it's one variable... What if I need to generate an email based on multiple questions with multiple answers each? ??

Highlighted
Regular Contributor

Was about to write the same but @ndwilliams3 was a little quicker than me Smiley Happy

 

Maybe some additional Infos about how to create Smart Content in emails:

 

1. Segment your different groups of contacts in different lists (f.e. List1: property 1 = yes, List2: property 2 = yes) 

 

Bildschirmfoto 2016-12-02 um 13.50.18.png

2. Rich-Text-Modules in emails can be made smart (based on lists or lifecycle-stages):

 

Bildschirmfoto 2016-12-02 um 13.52.33.png

 

3. Choose your Lists and create a different email copy for each group of contacts.

 

Bildschirmfoto 2016-12-02 um 13.52.56.png

Bildschirmfoto 2016-12-02 um 13.57.25.png

 

Best regards

Thomas

New Contributor

Thank you for the information, I expect that is probably the way I will have to do it, it just seems stupid to create 6 lists for something that chould be a simple if/then. Of couse I did also have to create 7 workflows to calculate the answers because in HS you cant have simultaneous if/then statements. Smiley Happy

BiG
Regular Contributor

I totally agree!!

This is in no way professional email marketing.

If you agree, too, please support this idea which queries for if statements in HUBL for emails:

Thank you very much!
Reply
0 Upvotes