Hola! ¡Tenemos nuestra Comunidad en Español!

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

Regular Contributor

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 %}

3 Replies 3
Community Thought Leader

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


Welcome @Zoomi. 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


Hope that helps.




Remote  B2B Digital Marketing Manager


MFrankJohnson.com | Connect on LinkedIn

Find posts quickly ... accept this solution now.

Hope that helps.





Regular Contributor

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

New Contributor

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