Personlized content in programmable emails

Hi we have an enterprise account and need a help.

Here is what we do currently,

However when I try to code personalized content with the code block

{% if contact.email == “example@example.com” %}

TestContent 1

{% else %}

TestContent 2

{% endif %}

it always results in for contact example@example.com which means it doesn’t work as expected.

My Question: do programmable emails support contact properties via Hubl in email templates or not? (as per my tests it doesn’t)

If yes, can anyone help me with how to make this work?

{% if contact.interest== “italy” %}

Display Italy related Content

{% else %} Display General travel Content

{% endif %}

Hey @vpetr,

how are you testing/previewing the email/template?

Just asking because if you’re clicking the Preview button in the top right inside the Design-Manager, personalization doesn’t work.
To see and experience personalized content the best practise is to:

  1. Create a new email with your template
  2. Preview the email via “Preview as contact”

  1. During the preview choose between one or more contact(s) with different properties that are used for your personalization rules (if-statements)

edit:
You can also set a preview contact if you should choose “Send test email”. This will send a test mail to the first email address (Send test to) as it would be the second one (Preview as contact)

best,

Anton

I’m sending a real blast as a test to few test contacts.

@vpetr - I have been using the feature recently with a set of custom objects. It looks from your first screenshot like you have set things up as I might expect, but I don’t understand your second screenshot. My testing of this feature is always in the email editor where you are able to preview the potential content for any given target contact record.

My usual approach when I’m faced with HubL problems is to use the {{ variable | pprint}} statement liberally to verify that settings are as I expect them to be. When I emply that sustematically, I find that I have missed some small logic step.

Hope this is helpful

Steve

Hi @vpetr

Yes, HubSpot’s programmable emails fully support using contact properties with HubL (HubSpot Markup Language). If everything is set up correctly, your test should work just fine.

If it didn’t work as expected, here are a few things you should check:

  1. Enable Programmable Email Beta:

HubL logic (like using contact.email or contact.interest) only works in emails if the “Programmable Email Beta” feature is turned on.

  • For Modules: When editing your module, make sure the “Email templates” option is checked and the toggle for “Enable module for programmable email beta” is turned on in the right sidebar.
  • For Custom Templates: Add this line at the very top of your template file:

isEnabledForEmailV3Rendering: true

  1. Use the Correct Internal Property Name:

HubL uses internal property names — not the display labels you see in the UI.

  • For default properties like email, use contact.email.
  • For custom properties, go to Settings > Properties, find the property, and use the internal name shown there (e.g., contact.interest, not necessarily just “Interest”).
  1. Test Properly:

Make sure you’re testing with real contact data.

  • In the email preview, choose “Preview as a specific contact” and pick one that actually has the relevant property values (like “italy” for interest).
  • If the selected contact doesn’t have a matching value, HubSpot will show the else condition.
  • Best test? Actually send the email to a few test contacts with different values to confirm it’s working.
  1. Check for Caching or Publishing Issues:

If you made changes to your module or template, publish them again. HubSpot sometimes uses cached versions unless manually updated.

  1. Check Where You Placed the HubL Code

Make sure the HubL logic isn’t being blocked or overridden by other parts of your HTML. Keep it clean and well-placed in your email body.

Example Template

Here’s how a working version of your email might look:

<!doctype html>
<html>
<head>
 <meta charset="utf-8">
 <title>Your Personalized Email</title>
</head>
<body>
 <h1>Hello {{ contact.firstname|default("there") }}!</h1>

 {% if contact.interest == "italy" %}
 <p>Explore Italy: Discover amazing tours of Rome, Florence, and Venice!</p>
 <img src="https://example.com/italy_promo.jpg" alt="Italy Travel">
 {% else %}
 <p>Explore the world: Check out all our travel destinations.</p>
 <img src="https://example.com/general_travel.jpg" alt="General Travel">
 {% endif %}

 <p>This email was sent to {{ contact.email }}.</p>
 {{ unsubscribe_link }}
 {{ site_settings.company_name }}
 {{ site_settings.company_street_address_1 }}, {{ site_settings.company_city }} {{ site_settings.company_state }} {{ site_settings.company_zip }}
</body>
</html>

In short: Make sure the programmable email feature is enabled, use the correct internal property names, preview/test it with real contact data, and publish updates. Once all that’s done, your personalization logic should work smoothly!

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.

Thanks!