E-mail Marketing (ESP)
David Addison
by David Addison
share this
« Back to the Blog

Dear First Name Personalization with Konvey


We’re going to examine a slightly more advanced personalization merge code. With Konvey we can use inline and function-based JavaScript mixed in with the merge syntax.

Let’s say that I want to personalize an e-mail with “Dear firstname” (eg. firstname is the database field name). Let’s further assume that the data in my database, like most, is far from perfect. This means that I have some names that are camelback cased (correctly), some that are all capital letters, some all lower letters, and some database records missing the firstname altogether. This is representative of my data.

  • David
  • david
  • (blank)

In this scenario, I would like to leave alone names that have a capital first letter (e.g. David and DAVID). I’m going to let the all capital letters names stay as they are because I don’t want to offend MCDONALD with Mcdonald.

Casing names is very difficult. If you move into the international realm, casing is nuts. I have never seen a computer system which handles names properly. Names are best input correctly by humans. Amazon.com, eBay and many of the world’s largest marketplaces don’t bother with casing issues. Their order receipts and packing lists contain information as it was typed by the end user (e.g. all caps, no caps, wrong casing…). This is certainly an approach. You cannot assume that lower-case followed by upper-case is wrong because Irish names break our USA first name first letter capitalized convention. Nonetheless, we’re going to show you how to capitalize the first letter of the first name if it is not already capitalized because this is a common want.

The merge code below will transform that data as follows:

David to Dear David:
david to Dear David:
(blank) to Dear Camper:

This merge code will convert the first letter to a capital letter and will inject the word camper if firstname is missing (to be more precise - either blank or NULL) altogether.

Dear {% contact.firstname ? contact.firstname[0].toUpperCase() + contact.firstname.substring(1) : “Camper” %}:

[If you copy this merge code for use on a template, be sure to convert the curly quotes back to straight.]

This merge code can be used in both the HTML and the Text template. I’m fairly certain that the code is self-explanatory.

If you’re familiar with JavaScript, you’ll notice that Konvey uses server-side JavaScript to format the casing of letters. You are free to use JavaScript anywhere you like within a merge code. Keep in mind that merge codes are case sensitive. So is JavaScirpt.




Thank you for contacting us!

We'll be in touch!

Back Home ×