• Home
  • Introduction to Pardot HML with Conditional Logic

Introduction to Pardot HML with Conditional Logic

For years, Pardot has used a proprietary language called PML, or Pardot Merge Language for merge fields in Emails, Advanced Dynamic content, and Landing Pages. Since the acquisition by Salesforce, the primary focus on the Pardot Engineering & Development teams are to make the platform more compatible and synchronous with Salesforce.

Over there years, there have been many improvements made. Recently, one of those changes is the migration to the Salesforce Proprietary Merge field language, Handlebars Merge Language, or HML.

One of the new tools that HML makes available is the ability to use the #if statement.

Introducing Handlebars Merge Language for Pardot: Ensure Perfect Personalization Every Time

Here’s an example of Conditional HML Merge Fields in Pardot:

{{#if Recipient.FirstName}} {{Recipient.FirstName}} {{else}}Hello{{/if}},

Here’s an example of Conditional HML Merge fields in the wild:

Email: We’ve got a special offer for you, Ken!

If you don’t know your recipient’s first name, what tends to happen is an awkward sentence, or worse, a grammatical error. The sentence above, for example, would become: We’ve got a special offer for you, ! 

In the past, we could set global defaults for our fields in Pardot. For example, in our field configuration from the Pardot Admin settings, we set a global default for the FirstName field. The global default would be Friend or Customer, but that feels unnatural. What if we just left it out completely, but made sure the punctuation looked right?

Here’s how you can solve this with #if:

{{#if Recipient.FirstName}}! // First we'll check for the first name
We've got a special offer for you, {{Recipient.FirstName}}! // Here's the content if we have a First Name
{{else}} // What to do if there is no first name?
We've got good news for you!
{{/if}} // End the #if statement

This will produce two versions of your email, personalized and formatted correctly.

Leave a Reply

Your email address will not be published. Required fields are marked *