Email Marketing Tool

andys2p
Participante

HubL using custom contact properties in if statements in an email template using Design Manager

resolver

Hello,

 

I want to use an email template for an email which will be used in a workflow. I created the template using Design Manager.

 

In contacts I defined prop1 and prop2 properties which are "Single-line text" type. prop1 and prop2 are updated using API calls from our platform and in case these are invalid or not yet set in our platform, I update them with 'N/A' value.

 

In email template I want to show a specific text for prop1 only if prop1 is not 'N/A' and another text if prop2 is not 'N/A'. To achieve this I added following code in email template:

 

PROP1: [{{ contact.prop1 }}]
{% if contact.prop1 != 'N/A' %}
  Property 1 is valid: [{{ contact.prop1 }}]
{% endif %}

PROP2: [{{ contact.prop2 }}]
{% if contact.prop2 != 'N/A' %}
  Property 2 is valid: [{{ contact.prop2 }}]
{% endif %}

When I edit the email which uses above email template and go to "Preview", choose a contact which has prop1 set to 'N/A' (without quotes) and prop2 set to 'Something here', the result in the preview is:

 

PROP1: [N/A]
  Property 1 is valid: [N/A]

PROP2: [Something here]
  Property 2 is valid: [Something here]

I searched other issues related to my problem, I tried using contact.prop1.value, contact.prop1|string != 'N/A'|string to be sure is not something related to prop1 type. Nothing works...

 

Any help is much appreciated.

 

Best regards,

Andy

 

1 Soluciones aceptada
MatthewShepherd
Solución
Asesor destacado

HubL using custom contact properties in if statements in an email template using Design Manager

resolver

Hi @andys2p 

 

Unfortunately, personalization variables in HUBL if statements are not supported in emails: https://designers.hubspot.com/docs/hubl/hubl-supported-variables

 

"Please note that using personalization variables (contact and company variables) within if statements is not currently supported for email in HubSpot. These variables can be used for logic on HubSpot CMS pages and blog templates."

Could you perhaps achieve what you are looking for by putting contacts in Contact Lists based on their contact record prop1 and prop2 values and then use Smart Content in your emails to show different content blocks to your different contact lists?

Matthew Shepherd

Freelance HubSpot Consultant
CRM Consultant | SEO Specialist

Did my post help answer your query?Help the community by marking it as a solution.

Ver la solución en mensaje original publicado

3 Respuestas 3
MatthewShepherd
Solución
Asesor destacado

HubL using custom contact properties in if statements in an email template using Design Manager

resolver

Hi @andys2p 

 

Unfortunately, personalization variables in HUBL if statements are not supported in emails: https://designers.hubspot.com/docs/hubl/hubl-supported-variables

 

"Please note that using personalization variables (contact and company variables) within if statements is not currently supported for email in HubSpot. These variables can be used for logic on HubSpot CMS pages and blog templates."

Could you perhaps achieve what you are looking for by putting contacts in Contact Lists based on their contact record prop1 and prop2 values and then use Smart Content in your emails to show different content blocks to your different contact lists?

Matthew Shepherd

Freelance HubSpot Consultant
CRM Consultant | SEO Specialist

Did my post help answer your query?Help the community by marking it as a solution.
andys2p
Participante

HubL using custom contact properties in if statements in an email template using Design Manager

resolver

Hi Matthew,

 

Thank you for your quick response.

 

I see what you mean, but we cannot do lists based on property values as we have lots of values set for each contact individually and there should be lots of if's in the template.

 

Do you know if there is in backlog to add this functionality to email templates, and if yes, when would this be available?

 

As quick solution for whoever wants to implement same functionality, I think we would create the blocks of HTML to embed in email template (using contact properties) in our framework and we will update the properties with HTML code already formatted and in email template we would just put {{ prop1 }}{{ prop2 }}...{{ propX }}.

 

Thank you!

Andy

0 Me gusta
MatthewShepherd
Asesor destacado

HubL using custom contact properties in if statements in an email template using Design Manager

resolver

This functionality has been requested a few times in the Hubspot ideas forum so you can upvote to try and get it in front of the Hubspot product team:

 

https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907

 

https://community.hubspot.com/t5/HubSpot-Ideas/If-Statements-in-HubL-for-Email-Templates/idi-p/21678...

Also, some further interesting discussion here by @MFrankJohnson suggesting if statements might work in email if you are storing personalisation tokens in custom variables: https://community.hubspot.com/t5/CMS-Development/HubL-Limitations-In-HubSpot-Marketing-Emails-HubL-R...

Not sure if this functionality is on Hubspot's roadmap at the moment.

Matthew Shepherd

Freelance HubSpot Consultant
CRM Consultant | SEO Specialist

Did my post help answer your query?Help the community by marking it as a solution.