# Personalizing email content based on user profile variable

**URL:** <https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241>\
**Category:** Email Marketing Tool\
**Tags:** template-design\
**Created:** [July 10, 2019, 9:51pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241 "2019-07-10T21:51:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 10, 2019, 9:51pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/1 "2019-07-10T21:51:08Z")

</div>

Hi there,

Just reaching out to see if anyone can advise on how to personalize email content. The Smart Content feature becomes unwieldy when there’s numerous variables, so I’m hoping there’s an alternative.

On our B2C platform we use personalization tokens to insert user profile data - something like:

Welcome to

[Contact.BrandName]

!

For personalized graphics we use:

[https://www.website.com/files/images/](https://www.website.com/files/images/)

[Contact.BrandName]

-logo.png

Is there a similar way to program emails in Hubspot?

Thanks for the help!

Doug

---

<div class="post-metadata">

**Author:** ![MatthewShepherd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matthewshepherd/32/31314_2.png) [@MatthewShepherd](https://community.hubspot.com/u/MatthewShepherd)\
**Post date:** [July 11, 2019, 8:45am UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/2 "2019-07-11T08:45:42Z")

</div>

Hi @DougieD

Are you currently using [personalization tokens](https://knowledge.hubspot.com/articles/kcs_article/cos-general/how-to-use-personalization-with-your-content) to insert personalized email content? Or are you using [Smart Content](https://knowledge.hubspot.com/articles/kcs_article/cos-general/add-smart-content-to-your-website-pages-landing-pages-and-emails) to show different block of text with your the personalized values written manually? Inserting personalization tokens from the email editor toolbar is the first solution here.

If you are looking to avoid using this feature you could just enter the corresponding contact [HUBL variables](https://designers.hubspot.com/docs/hubl/hubl-supported-variables)(which is all the insert personalization token toolbar feature is doing for you)

`{{ contact.company }}`

or you could create [custom contact properties](https://knowledge.hubspot.com/articles/kcs_article/contacts/how-can-i-create-a-custom-property) and use HUBL to insert those

`{{ contact.mycustompropertyinternalname }}`

---

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 19, 2019, 4:20pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/3 "2019-07-19T16:20:27Z")

</div>

Thanks, Matthew! I think the HUBL solution will work. Super appreciate your help!

---

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 19, 2019, 8:24pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/4 "2019-07-19T20:24:02Z")

</div>

Quick follow up if you have a moment …

I’m trying to build an if/else statement in HUbL but I don’t think I have it quite right.

I would like a snippet of code to appear if a user variable exists. If not, I would like it to default to a different snippet of code.

Here’s my code so far. Any ideas?

{% if contact.variable %}

\<img src=“[https://website.com//](https://website.com//){{ contact.variable }}.png”/\>

{% else %}

\<img src="[https://website.com/logo.png](https://website.com/logo.png) /\>

{% endif %}

---

<div class="post-metadata">

**Author:** ![MatthewShepherd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matthewshepherd/32/31314_2.png) [@MatthewShepherd](https://community.hubspot.com/u/MatthewShepherd)\
**Post date:** [July 22, 2019, 12:42pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/5 "2019-07-22T12:42:29Z")

</div>

Hi @DougieD

This looks correct…with the exception of the // in your img src url, there should just be a single forward slash before the contact variable, [https://website.com\*\*//\*\*](https://website.com//){{ contact.variable }}.png.

{% if contact.variable %} is checking to see if a contact property with an internal name of variable (in practice this would be something like contact.firstname or the actual internal name of your contact property) is defined. If the property variable has a value it should output your first image tag and if it has no value it should default to your second image tag.  
What is happening when you use this code?

---

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 22, 2019, 3:51pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/6 "2019-07-22T15:51:21Z")

</div>

Thanks so much, Matthew! It appears the merge values are working as exptected. I need the inserted value to be converted to lowercase, however. I tried this but it doesn’t seeem to be working. Any ideas?

[https://website.com\*\*/\*\*](https://website.com//){{ contact.variable|lower }}.png

---

<div class="post-metadata">

**Author:** ![MatthewShepherd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matthewshepherd/32/31314_2.png) [@MatthewShepherd](https://community.hubspot.com/u/MatthewShepherd)\
**Post date:** [July 22, 2019, 4:49pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/7 "2019-07-22T16:49:04Z")

</div>

{{ contact.variable|lower }} should work.

Is your variable a string? Does it contain any numbers etc.?

---

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 22, 2019, 7:43pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/8 "2019-07-22T19:43:00Z")

</div>

Thanks, Matthew. It’s a text string without numbers, like this:

[https://www.website.com/ABCD.png](https://www.website.com/ABCD.png)

It should be

[https://www.website.com/abcd.png](https://www.website.com/abcd.png)

It’s successfully pulling in the ABCD part but not converting it to lowercase.

Doug

---

<div class="post-metadata">

**Author:** ![MatthewShepherd](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matthewshepherd/32/31314_2.png) [@MatthewShepherd](https://community.hubspot.com/u/MatthewShepherd)\
**Post date:** [July 23, 2019, 8:23am UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/9 "2019-07-23T08:23:50Z")

</div>

Hi @DougieD

I forgot you were implementing this in an email template where filters on personalization variables aren’t supported:

“Please note that using filters on personalization variables (contact and company variables) is not currently supported for email in HubSpot. Filters can be applied to these properties on HubSpot CMS page and blog templates.”

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fcms%2Freference%2Fhubl%2Fhubl-supported-filters)**

A workaround could be to use [Zapier.com](https://zapier.com/apps/hubspot/integrations) to change the case of your contact property and store it in a separate field.

---

<div class="post-metadata">

**Author:** ![DougieD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dougied/32/23861_2.png) [@DougieD](https://community.hubspot.com/u/DougieD)\
**Post date:** [July 23, 2019, 3:04pm UTC](https://community.hubspot.com/t/personalizing-email-content-based-on-user-profile-variable/15241/10 "2019-07-23T15:04:49Z")

</div>

Thanks, Matthew! That makes sense. I really appreciate your help!

Doug
