FreeMarker: Common Uses

 << Understanding Basic Render Errors

 

At the most basic level, FreeMarker code is a great way to dynamically insert values from Lead/Contact/Account/User records into ClickDimensions email templates.  However, the scope for ways to use FreeMarker code is very large.  Here are some examples of other applications of FreeMarker code within email templates:

Insert Dynamic Content in Links

FreeMarker can be used to pull a value from CRM into a URL as a link parameter. This can be very useful if you are trying to gain more insight into your click and page view data.

When adding FreeMarker to a URL it is important that your interpolation does not include quotation marks following the exclamation point. Here’s what it should look like in the HTML:

<a href=”www.clickdimensions.com/?firstname=${Recipient.contact.firstname[0]!}”>Link Text</a>

If you do not remove the quotations marks from the interpolation, as shown above, your email will fail to send due to a render error. The error occurs because the quotations marks following the exclamation point prematurely close out the quotes surrounding the href’s URL, thus creating invalid HTML.

If you have a Freemarker-accessible field in CRM that contains a full URL, you can even use Freemarker to set the entire link URL. For example, if there is a “Branch Website” field on the Contact record that the URL for that Contact’s local branch’s website, you can set the link like this in the HTML:contains

<a href=”${Recipient.contact.new_branchwebsite[0]!}”>Your branch’s website</a>

As with all FreeMarker used inside links, be sure to remove the quotation marks following the interpolation’s exclamation point. If you don’t, you will get a render error due to invalid HTML.

Subject Line, From Name, & From Email

You can use a FreeMarker interpolation in an Email Send’s Subject Line, From Name, and From Email fields by simply placing the FreeMarker in the appropriate field on the Email Send record.

Email Send Dynamic Subject

You cannot use if-statements or other conditional FreeMarker in an Email Send’s Subject Line, From Name, or From Email; doing so will cause a render error, and the email will not send.

Time Stamps

You can also use FreeMarker to place time stamps into your emails:

Date only, no time: ${.now?date}
Time only, no date: ${.now?time}
Date and Time: ${.now?datetime}

Note: These are some of the only interpolations that render in Test Emails. They do not reference data on a specific record in CRM and thus do not need to be sent to a specific recipient in order to render. Data from records that have a Connection with the Email Send records will also render in Test Emails.


Feature Added: Original
Feature Updated: 6.7.0
ClickDimensions Version Need: 6.7.0
 << Understanding Basic Render Errors