This article covers dynamic content in Keap™ using Liquid — a template language that enables personalized email content based on contact tags and field values. Dynamic content can replace decision diamond workflows in Advanced Automations and is available in Broadcast emails and Advanced Automation email templates.
Important: Dynamic content requires knowledge of the Liquid template language, which is based on Ruby. Keap Technical Support does not assist with writing or debugging Liquid code. For learning resources, see Shopify's Liquid documentation, the Liquid open source reference on GitHub, and this overview at Monkeypod Marketing.
Getting Started With Dynamic Content
A practical first use of dynamic content is setting a fallback value for the first name field. If a contact does not have a first name in their record, standard merge fields may display blank text or broken code in an email. Using Liquid, a default value such as "friend" can be defined so that contacts without a first name see a natural greeting while contacts with a first name continue to see their name.
Frequently Asked Questions
What does this article cover?
This article covers how dynamic content works in Keap using Liquid syntax, including Liquid basics, code examples, and how to use Liquid in the email builder.
What is Liquid?
Liquid is a template language that enables dynamic content in emails. Similar to merge fields, Liquid inserts contact data into email content — but unlike static merge fields, Liquid supports conditional logic, fallback values, and calculated outputs such as formatted dates.
Is dynamic content available in all Keap editions?
Yes. Dynamic content using Liquid is available in all Keap editions including Max Classic.
Does dynamic content work with custom fields?
Yes. Liquid syntax can reference all contact fields including custom fields.
Where can dynamic content be used in Keap?
Liquid syntax can be used anywhere merge fields are available in the Keap application, including Broadcast emails and Advanced Automation email templates.
What types of dynamic content can be used?
HTML formatted text, hyperlinks, and images.
What can Keap Support help with for dynamic content?
Keap Support can assist with basic questions about the dynamic content editor. Keap Support does not assist with writing or debugging Liquid code. Bugs discovered in the dynamic content feature can be reported to Keap Support for escalation to the product team.
Liquid Syntax Overview
Liquid is a template language created by Shopify and written in Ruby. It is available as an open source project on GitHub and is used across many software platforms. In Keap, Liquid syntax is available in Broadcast Email and the Advanced Automation Builder email editor.
Before dynamic content, an Advanced Automation routing contacts into different email sequences based on field values might require multiple decision diamonds and separate sequences:
With dynamic content, the same logic can be handled within a single email using Liquid code:
The screenshot above shows how an Advanced Automation using Liquid dynamic content can replace a multi-branch decision diamond workflow with a single email step.
Selecting the dynamic content icon in the email opens the Liquid code editor:
The screenshot above shows the Liquid code editor in the Keap email builder.
Liquid Code Basics
Two Execution Phases
Keap executes Liquid in two phases to handle both static and time-sensitive merge fields:
Phase 1 — Resolves at the time an Advanced Automation is published. Uses double curly braces:
{{ merge field }}Phase 2 — Resolves at the time the automation runs and the email is sent. Uses double square brackets:
[[ merge field ]]
For example, using {{ today.date_and_time }} in an email merges the date the automation was published. Using [[ today.date_and_time ]] merges the date and time the email was actually sent to the contact.
Liquid Syntax Elements
| Element | Description | Syntax |
|---|---|---|
| Objects | Tell Liquid where to output content |
{{ }} or [[ ]]
|
| Tags | Control logic and flow for templates | {% %} |
| Filters | Modify the output of a Liquid object | Used within an output, separated by |
|
Operators
| Operator | Meaning |
|---|---|
== |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
or |
This OR that |
and |
Must be this AND that |
contains |
Contains |
Code Examples
Basic object output
| Code | Result |
|---|---|
{{ contact.firstname }} |
George |
Fallback values (defaults)
| Code | Result |
|---|---|
Hi {{ contact.firstname | default: 'there' }} |
Hi George (or Hi there if no first name is on file) |
Control flow — based on number of employees
| Code | Result |
|---|---|
{% if contact.numberofemployees > 50 %} |
With a large organization like yours, communication is key. |
{% elsif contact.numberofemployees > 5 %} |
In SMBs, the key is balance. |
{% else %} |
In a micro-org like yours, you need to save every dollar. |
{% endif %} |
Control flow — based on email domain
| Code | Result |
|---|---|
{% if contact.email1.address contains '@gmail.com' %} |
<a href="https://help.keap.com/help/gmail-sync">Gmail sync for Keap</a> captures the email communications in Gmail into your contact record. |
{% else %} |
<a href="https://help.keap.com/help/gmail-sync">Gmail sync</a> and <a href="https://help.keap.com/help/microsoft-sync">Microsoft email sync</a> for Keap captures email communications into your contact records. |
{% endif %} |
Date formatting
| Code | Result |
|---|---|
{{ today.date }} |
2019-08-13 |
{{ today.date | short }} |
8/13/19 |
{{ today.date | medium }} |
Aug 13, 2019 |
{{ today.date | long }} |
August 13, 2019 |
{{ today.date | full }} |
Tuesday, August 13, 2019 |
{{ today.date | plus_days: 14 | full }} |
Tuesday, August 27, 2019 |
Case statement — day-of-week personalization
Hello ~Contact.FirstName~,
~Date.DayOfWeek~
{% capture day %}{{ 'now' | date: '%A' }}{% endcapture %}
{% case day %}
{% when 'Sunday' %} Check out our Sunday specials!
{% when 'Monday' %} Check out our Monday specials!
{% when 'Tuesday' %} Check out our Tuesday specials!
{% when 'Wednesday' %} Check out our Wednesday specials!
{% when 'Thursday' %} Check out our Thursday specials!
{% when 'Friday' %} Check out our Friday specials!
{% when 'Saturday' %} Check out our Saturday specials!
{% endcase %} |
Use Liquid Code in the Email Builder
Liquid code can be added anywhere merge fields are available in Keap. The example below shows the day-of-week case statement above entered into a broadcast email:
The screenshot above shows a Liquid case statement entered in the Keap broadcast email editor.
The contact receives an email with the day-specific content inserted automatically:
The screenshot above shows the rendered email as received by the contact with the Liquid case statement resolved to the correct day-specific message.
Comments
0 comments