Using The First Name Code

  • 11 December 2020
  • 3 replies

Badge +2

Hi everyone,


I’ve been having a problem using the code to insert the customer’s first name into my emails. It seems like it works some of the time, and other emails I end up seeing just have a blank space. I sent out a holiday sale email this morning, and when I saw my copy, I realized it was just a blank space where the first name should be. This is very disappointing, embarrassing, and makes my emails look unprofessional because there is a comma, a space, and then an exclamation mark rather than a name inserted. Does anyone know how to ensure that the first name is always going to appear properly?


Thank you,



Best answer by retention 11 December 2020, 16:35

View original

3 replies

Userlevel 7
Badge +56

@greenpandamindbody Hi there.

I assume you’ve used this code to dynamically populate the First Name: {{ first_name|default:'' }}

In order for Klaviyo to display the first name of your subscriber in the email, you must have that information for your subscriber.

Usually, many brands have subscribers with the first name information and subscribers for which they only have their email address. I assume this is your case too.

Subscribers that you have in your account that have the first name information are usually customers who came into Klaviyo by purchasing something in your store. When they purchase something, they’re required to fill the checkout form and this is where they give you their first name. These are the subscribers for which the code {{ first_name|default:'' }} will successfully display their first name.

On the other hand, if the subscriber comes through a form (pop-up for example) that only requires him to enter his email address, you haven’t captured his first name. If you don’t have the first name of your subscriber, Klaviyo can’t know what to put there.

This is why the code {{ first_name|default:'' }} contains the |default:'' part.
Between the brackets in that part, you can put something generic that will be used for subscribers without the first name information.

Hi {{ first_name|default:'there' }}!

For subscriber (E.g. John) that you have the first name information it will display:
Hi John!

For subscriber that you don’t have the first name information it will display:
Hi there!

Hope this clarifies how this works.

Badge +2

This helped a lot, thank you!

Userlevel 4
Badge +6

How can you add the customers first name into subject line and ensure that the first letter is in caps as often customers add their first name in lower case by mistake?