Tutorial: Creating Your First Pardot Handlebars Email Template With Conditions

I've been testing Pardot's new Handlebars Merge Field feature this week and wanted to publish my exact test steps.  If you are just getting started with Pardot or curious how to use this new feature I hope this tutorial will help you understand the basics.  Keep a watch out for an expanded tutorial walking you through the full process of creating an automated personalized content newsletter using FeedOtter for Pardot and the new Pardot handlebars (HML) feature.

Step 1. Create 4 Prospect custom fields. I used my favorite barnyard animals.

  • chicken_content
  • dog_content
  • fish_content
  • horse_content

All of these fields are type CHECKBOX with one value 'TRUE' and no default value. This is important because the handlebars conditions only evaluate empty OR set. The actual value doesn't matter and cannot be compared against at this time.

Create a pardot custom field

Step 2. Edit a non-important prospect and set any 2 of the new custom fields to TRUE

Adjust Pardot custom fields

Step 3. Create a new Email Template and paste in the following code:

{{Recipient.FirstName}},

Here is the content you asked for and nothing else:

{{#if Recipient.fish_content}} Fish Content{{/if}}
{{#if Recipient.dog_content}}Dog Content{{/if}}
{{#if Recipient.horse_content}}Horse Content{{/if}}



Regards,
{{Sender.Name}}
{{Sender.Title}}
{{Sender.Phone}}

You are receiving this email because you signed up to receive our monthly newsletter at http://www.example.com
Unsubscribe from email communications

{{{Organization.Address}}}

PRESTO! Now click the preview tab and select the contact whose fields you set to TRUE in step #2.  You will see that you email only shows Dog and Chicken content not all 4!

Demonstrate how Pardot's HML conditions work.

It's Not Perfect Yet

While this advancement is a major step forward and super-exciting there are a couple improvements I immediately have asked for such as:

1. The ability to chain {{#if}} {{#elseif}} statements. 

During testing I wanted to create several sections of content shown only to user's with matching custom field values. Because here is no way to do an ELSEIF and chain several statements together it is possible to send an email where no content is shown.  An ELSEIF would allow me to create a default content area where I could display general content to those who did not match other conditions.

2. The ability to condition based on list name e.g. {{#if recipient.List.my_list_name }}

For my immediate use case I wanted to change which content was shown based on preferences set on an email preference center page BUT preference centers only allow me to opt users into and out of lists.  To get around this I created a number of Automation Rules to set and unset custom field values when a user enters or leaves a list.  Do-able but a bit tedious.

3. Actual comparison

I suspect this was left out to keep things simple but adding the ability to say {{#if Recipient.dog_content = "1"}} would be nice.  As it is now the IF statements only compare if the field is set  IE any value will equate to TRUE and thus the content being shown.  It works, you just have to setup your fields carefully with this in mind.

 

Important Pardot Handlebar Links:

List of all Pardot handlebars merge codes

Pardot explanation of how to use conditionals with the new handlebars tokens

FeedOtter Can Help You Automate Blog and RSS Email

Promote your content and increase revenue from website traffic.
REQUEST A DEMO