ClickDimensions
ClickDimensions
ClickDimensions
ClickDimensions

Using FreeMarker to Create a Flawless Email Introduction

by clickdimensions

Creating personalized emails has never been easier with the ClickDimensions personalization tool. However, things can sometimes get a little tricky if you’re sending an email to both leads and contacts. Often the placeholder text can interfere, making the email introduction look a little clunky.

By utilizing the assign statement, we can be confident that the right introduction is presented every time we send an email. First, let’s take a look at how to build an assign statement and what it does.

An assign statement will assign a specific value to a variable. Think of it as a shortcut that makes writing the same interpolation multiple times so much easier. Here’s an example:

<#assign fname=Recipient.contact.firstname[0]!”Customer” />

This statement assigns whatever value is held in Recipient.contact.firstname to the variable fname. So, once the assign statement has been written, we can now type the following:

${fname}

So essentially:

<#assign fname=Recipient.contact.firstname[0]!”Customer” /> ${fname}

Is the same as:

${Recipient.contact.firstname[0]!”Customer”}

In the case of the above contact, both snippets of code would produce the value of Lewis “The Lazer.”

At this point, you might be thinking that writing this out using the assign statement seems like a lot more work. However, if you have the recipient’s first name in multiple places in an email, it makes writing out the code a whole lot faster.

Now that we understand how the assign statement works, let’s examine creating that flawless introduction. If we are sending an email to leads and contacts, you would often see the following code written:

Hi ${Recipient.contact.firstname[0]!”Customer”}${Recipient.lead.firstname[0]!””}

While sending this to a Contact with a value for first name will produce a correct result, sending this to a lead will cause issues. Since a lead does not have a value for contact.firstname, the word contact will always appear before the lead’s name.

So how can we ensure the correct greeting each time? We can use an assign statement. Consider the following code snippet:

<#assign leadfname=Recipient.lead.firstname[0]!”Customer” />

${Recipient.contact.firstname[0]!leadfname}

Let’s break this down:

Contacts
Lewis is a contact we are sending the email to, so the first part of the interpolation applies (Recipient.contact.firstname) and the value of Lewis “The Lazer” will be populated.
Leads
Oscar is a lead we are sending an email to, so the first part of the interpolation will not apply. This means the engine will look to the placeholder for the stand-in value. Because the stand-in value is a variable referencing Recipient.lead.firstname the email will populate in with the value of Oscar.
Accounts or contacts/leads with no first name value
Finally, if we send this email to an account record – the first interpolation references a contact, which is not applicable so we reference the placeholder. The placeholder references a lead, which is also not applicable. In our assign statement we put in a placeholder for the lead interpolation of “Customer.” Because neither of the two interpolations applied, a value of Customer will be displayed. This also rings true for any lead or contact that does not have a value for first name.

By using this method of combining assign statements with placeholders, we can ensure the right message is sent every time without worrying about placeholders showing incorrectly.

Happy Marketing!

Related Resources

Go to Top