Update: I got to the end of writing this and realised I could actually achieve what I needed by creating a custom module with some smart content in it. (which is a better and more scalable, versitile way of doing things anyway). However, if anyone can be bothered reading through the below, I’d still be interested to know what I was doing wrong with my other approach (non urgent, so only if you’re feeling bored
![]()
:
Scratching my head a little here - I’ve got a contact property called Primary Subscription which I’d like to use in a conditional statement in our email templates to display a different header based on what the contact’s Primary Subscription property value is.
When I simply add {{ contact.primary_subscription }} to the template, it works fine - the value is output to the email body as expected in both the preview inside HubSpot and when sent as a preview email.
However, using it in the below code doesn’t seem to work, the default is always served when previewing the email, even when I can see ‘EXJournal’ output at the top of the message, which matches the value I’m using in the if statment.
{% if contact.primary_subscription == "EXJournal" %}
<tr id="logo-header">
<td align="center" class="bodyContent roboto-text" style="text-size-adjust: 100%; font-size: 14px; line-height: 15px; padding: 20px;{% if widget_data.show_header.value == 'Hide' %} padding-top: 40px;{% endif %} text-align: left; background-color: #FFFFFF; border-radius: 5px 5px 0px 0px;" valign="top"> <a href="{% text "main_website_link" label="Main Website Link", value="https://www.joyoushq.com", no_wrapper=True %}{% text "tracking_string" label="Tracking String", value="?utm_source=email&utm_channel=nurture&utm_campaign=customer_welcome", no_wrapper=True %}" style="text-align: center"> <img alt="" border="0" src="https://pulse.joyoushq.com/hubfs/images/exjournal/EXJ-Logo-gradient-455px.png?noresize" width="200" style="width:200px; margin: auto; max-width: 80%; border-width: 0px; border-style: solid;" /> </a> </td>
<td align="center" class="bodyContent roboto-text" style="text-size-adjust: 100%; font-size: 14px; line-height: 15px; padding: 20px;{% if widget_data.show_header.value == 'Hide' %} padding-top: 40px;{% endif %} text-align: right; background-color: #FFFFFF; border-radius: 5px 5px 0px 0px;" valign="top"> <a href="{% text "secondary_website_link" label="Secondary Website Link", value="https://www.joyoushq.com", no_wrapper=True %}{% text "tracking_string" label="Tracking String", value="?utm_source=email&utm_channel=nurture&utm_campaign=customer_welcome", no_wrapper=True %}" style="text-align: center"> <img alt="" border="0" src="https://pulse.joyoushq.com/hubfs/images/logos/joyous-logo-black-400px.png?noresize" width="150" style="width:120px; margin: auto; margin-top: 4px; max-width: 80%; border-width: 0px; border-style: solid;" /> </a> </td>
</tr>
{% else %}
<tr id="logo-header">
<td align="center" class="bodyContent roboto-text" style="text-size-adjust: 100%; font-size: 14px; line-height: 15px; padding: 20px;{% if widget_data.show_header.value == 'Hide' %} padding-top: 40px;{% endif %} text-align: center; background-color: #FFFFFF; border-radius: 5px 5px 0px 0px;" valign="top"> <a href="{% text "main_website_link" label="Main Website Link", value="https://www.joyoushq.com", no_wrapper=True %}{{ widget_data.tracking_string.value }}" style="text-align: center"> <img alt="" border="0" src="https://pulse.joyoushq.com/hubfs/images/logos/joyous-logo-400px.png?noresize" width="200" style="width:200px; margin: auto; max-width: 80%; border-width: 0px; border-style: solid;" /> </a> </td>
</tr>
{% endif %}
I feel like I must be either doing somehting completely dumb or missing some subtlty in how I’m referencing the field, however can’t spot anything in the docs, so hoping someone can point me in the right direction. Have tried the following:
- Setting a variable at the top of the template and referencing that instead
- Referencing via request_contact.contact.primary_subscription instead (same result, this is output to the template, but innaccessible in the if statement)
- Removed the other conditional statements inside the if statement, just in case adding one inside another was causing an issue for some reason - made no difference.
- Tried using single quotes or double quotes
- Tried using .value on the end
Any help/correction/magic ideas appreciated!
*For context: I do currently have this setup as a conditional section in the email (ie have made the header as a smart piece of content which is dependent on this field) , however, we’re expanding our content library and also likely to add additional subscription branding options in the near future, so don’t want to have to keep maintaining multiple options at an individual email level. Unless I’ve missed something having it coded at the template level is the best way of doing it?
