Home | Dynamic Content | Simple FreeMarker Examples for Personalizing Emails

Simple FreeMarker Examples for Personalizing Emails

If you are in marketing, you probably have heard a lot about personalization in email marketing. Personalization is all about identifying characteristics of your recipients that are relevant to the email you want to send and then customizing that content with the most relevant data. It could be a recipient’s name, the city where they live or even their favorite food – you are only limited by the information you have in your CRM. This is known as dynamic content, and in ClickDimensions, dynamic content is done with FreeMarker.

Before using FreeMarker in your ClickDimensions email templates, make sure that you have gone to Settings > ClickDimensions Settings and published your metadata. This publishes your customizations to ClickDimensions so that your custom fields will appear in the personalization menu.

The personalization menu in ClickDimensions email editors will generate FreeMarker that looks something like this (your field’s schema name may vary): ${Recipient.contact.new_profilelink[0]!””}

Here are some examples of simple references that can be made using the personalization button.

Freemarker in Template Rendered Message
Hello, ${Recipient.FirstName}!

Hello, Sam!

I see your favorite

color is ${Recipient.FavoriteColor}

I see your favorite color is



“Valued Customer”}

Dear Valued Customer (if no data is available)
You were born on ${Recipient.contact.birthdate[0]?string[“dd.MM.yyyy, HH:mm”},

Happy Birthday!

You were born on October 16th 1988 at 4:08am,

Happy Birthday!

This month’s campaign is



This month’s campaign is Campaign 003



Good Morning, ${Recipient.contact


Good Morning, Dr. Anderson

Another way to use FreeMarker is using if, else if and else statements, known as conditional statements. You can use if, else if and else directives to conditionally skip a section of the template.

For example, if you wanted to create a template in a different language based on what a contact’s language preference is, you can assign that information.

FreeMarker in Template – Here is an example of how to assign a language into your content depending on the data in the field.
<#assign x=Recipient.contact.ava

<#if x==”de-DE”>
<#if x==”it-IT”>
<#if x==”es-ES”>
<#if x==”fr-FR”>
<#if x==”Null”>

FreeMarker in Template – Here is an example of how to assign gender into your content.

<#assign gender=Recipient.contact.gendercode[0]!”null”/>
if gender==”Male”>
<#elseif gender==”Female”>
<#elseif gender==”null”>
<#elseif language==”English”><#if gender==”Male”>
<#elseif gender==”Female”>
<#elseif gender==”null”>

Happy Marketing!

2017-08-29T09:03:52+00:00 By |Dynamic Content, Email Marketing|5 Comments

About the Author:

Sam Ngaima is a ClickDimensions Product Consultant.


  1. Julian October 10, 2017 at 11:14 pm - Reply

    Hi Sam, this post is about reflecting back to recipients the information we hold about them. This is very valuable in many contexts but in ours we find that recipients want unique content based on what we know about them. For example, if someone likes blue t-shirts we can show them the blue t-shirts we have for sale, not just acknowledge that they like blue t-shirts. And if they like red t-shirts we can show them the red ones etc. I understand Freemarker can be used to create an email with both blue and red t-shirts in it, but then we can only display the appropriate coloured t-shirts to each user based on their preferences. It would be awesome if your next post could address this please 🙂

  2. Priti Pipalia April 17, 2018 at 6:39 am - Reply

    Hey Sam,

    This post is really helpful. Referring to the last example, I am trying this FreeMarker to get the Campaign Id from Email Send:

    It returns a blank value every time, although it contains a value. Is there anything missing/incorrect here?

Leave A Comment