In this article
- How personalization works in Drip
- Drip specific shortcodes
- Data needed for personalization
- How to apply personalization
- Rendering dates and times in emails.
How personalization works
Drip is integrated with a templating language called Liquid. Created by Shopify, Liquid allows you to dynamically insert your subscribers' individual data into the emails you send to them. Probably the most common use case for this would be to greet subscribers by their first names at the beginning of an email.
If you aren't familiar with Liquid up to this point, we've put together a short Liquid Guide to help you get going. In that guide, you'll learn about the Liquid shortcodes that we've created for Drip specifically.
The following is an example of such:
{{ subscriber.email }}
As you can see, the shortcode opens and closes with sets of curly braces. You are free to include additional text on either side of the shortcode.
Here is an example of that shortcode being used in an email:
Here is how the email would be rendered and sent to a subscriber with an email address of “erika@company.com”:
Previewing Your Liquid Shortcodes
When working with Liquid, you can preview how your emails will appear by viewing it under the Preview tab in the email editor.
You can preview how the email will render for a specific subscriber by entering their email address in the Preview as a subscriber sidebar to the right of the email editor:
Drip specific shortcodes
In your email editor, go to the HTML tab, then click View Shortcodes:
You'll see all of the Drip specific shortcodes that you can use throughout your emails. Again, if you're just getting started with Liquid, we suggest you check out our Liquid Guide.
Dynamic Subscriber Data | Liquid Shortcode |
---|---|
Email Address | {{ subscriber.email }} |
Time Zone | {{ subscriber.time_zone }} |
id | {{ subscriber.id }} |
utc offset | {{ subscriber.utc_offset }} |
Visitor UUID | {{ subscriber.visitor_uuid }} |
Status | {{ subscriber.status }} |
Friendly Time Zone | {{ subscriber.friendly_time_zone }} |
Tags | {{ subscriber.tags }} |
created at | {{ subscriber.created_at }} |
Lead Score | {{ subscriber.lead_score }} |
EU Consent | {{ subscriber.eu_consent }} |
Campaign Name | {{ campaign.name }} |
Next Email Sending Time | {{ campaign.next_email_send_at }} |
“From” Name | {{ from_name }} |
“From” Email | {{ from_email }} |
Postal Address | {{ postal_address }} |
Inline Postal Address | {{ inline_postal_address }} |
HTML Postal Address | {{ html_postal_address }} |
“View In Browser” URL | {{ view_in_browser_url }} |
Opt-In Confirmation URL | {{ confirmation_url }} |
Unsubscribe URL | {{ unsubscribe_url }} |
Manage Subscriptions URL | {{ manage_subscriptions_url }} |
“View In Browser” Link (permalink) | {{ view_in_browser_link }} |
Opt-In Confirmation Link | {{ confirmation_link }} |
Unsubscribe Link | {{ unsubscribe_link }} |
Manage Subscriptions Link | {{ manage_subscriptions_link }} |
Current Time | {{ now }} |
Date Filter: Current Time in Unix | {{ now | timestamp }} |
Date Filter: Current Time rendered in M, D, Y format | {{ now | date: “%a, %b %d, %y” }} |
Date Filter: Seven days from now (adding seven days in Unix) | {{ now | timestamp | plus: 604800 }} |
Date Filter: At midnight, seven days from now | {{ now | at_midnight | timestamp | plus: 604800 }} |
Date Filter: Current Time in a Specific Time Zone | {{ now | in_time_zone: “America/New_York” }} |
Date Filter: Current Time in a Subscriber’s Time Zone | {{ now | in_time_zone: subscriber.time_zone }} |
Drip specific filters
Example Usage
advance_date_to_next | {{ now | advance_date_to_next }} |
at_midnight | {{ now | at_midnight }} |
days_since | {{ "January 1, 2018" | date: "%b %d, %y" | days_since }} |
days_until | {{ "January 1, 2019" | date: "%b %d, %y" | days_until }} |
default | {{ your_variable | default: “Your default text” }} |
hmac_sha256 | {{ your_variable | hmac_sha256: “A private key” }} |
hyperlink | {{ your_variable | hyperlink }} |
in_time_zone | {{ now | in_time_zone }} |
md5 | {{ your_variable | md5 }} |
replace_inner_html | {{ unsubscribe_link | replace_inner_html: “New text goes here” }} |
strip_commas | {{ your_variable | strip_commas }} |
timestamp | {{ now | timestamp }} |
url_encode | {{ your_variable | url_encode }} |
weeks_since | {{ now | weeks_since }} |
weeks_until | {{ now | weeks_until }} |
Data needed for personalization
The most common way to collect data that can be dynamically inserted into emails is through information your subscribers give you when filling out your opt-in forms. That data is automatically stored in custom fields.
If you have imported subscribers into your Drip account with information other than the required email address, Drip will store that information in custom fields.
Third party integrations and APIs will oftentimes send data into Drip as custom fields.
Go to Subscribers > Custom Fields to see a list of your custom fields.
There’s a good chance that your custom fields will be different from the ones seen in the screenshot above.
How to apply personalization
Dynamically inserting subscriber custom fields
All subscriber custom fields are available for use in emails. Some platforms use merge tags or other dynamic methods to achieve the same result.
Shortcode syntax:
{{ subscriber.custom_field_identifier }}
The predefined variable “subscriber” does not need to be modified.
Include Liquid shortcodes wherever you would like dynamic subscriber data to be inserted.
Here is an email example using the “first_name” and “registration_status” fields in the email:
Once you've added some personalization to an email, you can go to the Preview tab to make sure everything is rendered correctly:
This will all work great if you have that data saved for every subscriber that you send the email to, but that might not be the case.
Here's how that same email will render for a subscriber that we do not have a value saved for their first name:
As you can see, an undesirable space is created where the first name should be. This is because we do not have that particular subscriber's first name. Luckily that's a pretty easy fix.
Using Liquid’s "default" filter, you can set default text for subscribers that do not have values for the custom fields you are using in the shortcode.
Setting default text
Shortcode syntax using the default filter:
{{ subscriber.custom_field_identifier | default: "your default text" }}
Here is how the example shortcodes would be modified to insert default text:
{{ subscriber.first_name | default: "there" }}
and
{{ subscriber.company | default: "your company" }}
The filter is separated from the rest of the shortcode by a pipe character. Between the double quotes, insert whatever default text you would like to appear.
Now any subscribers that do not have values for the custom fields will see that same email as:
Alternatively, if you have a field that isn’t set on every subscriber, you can use Liquid tags to check whether a subscriber has a value set for a particular field before inserting it:
Hi{% if subscriber.first_name %} {{ subscriber.first_name }}{% endif %},
Since “{{ subscriber.first_name }}” will only be rendered if the subscriber has a first name value set, a subscriber with no first name set will receive this:
Capitalization
You might have some subscriber fields that need to be capitalized when displayed in emails. To fix this, you can use the capitalize filter:
{{ subscriber.custom_field_identifier | capitalize }}
That filter will capitalize the outputted data for any field that is not already.
Using Subscriber Tags to Dynamically Change Email Text
Typically, tags aren’t inserted directly into emails, but can instead be used in conditionals to display different content for different subscribers based on their tags.
For example, you might have 3 different segments of subscribers tagged according to their business size. Using conditional statements allow you to present the right content to the right subscribers:
{% if subscriber.tags contains "Small Business" %} Subscribers tagged with "Small Business" will see this content. {% elsif subscriber.tags contains "Mid-size Business" %} Subscribers tagged with "Mid-size Business" will see this content. {% elsif subscriber.tags contains "Enterprise Business" %} Subscribers tagged with "Enterprise Business" will see this content. {% endif %}
Conversely, if you only want to show text if a tag is not present, use this:
{% unless subscriber.tags contains "Customer" %} Subscribers without the "Customer" tag will see this content. {% endunless %}
This is useful if you need to include a call to action, but not show it for subscribers who have already converted.
Rendering dates and times in emails
You can use Liquid to display dates and times in your emails.
A few of the date and time shortcodes bear explanation:
{{ campaign.next_email_send_at }}
In a campaign email, this will insert the date and time at which a subscriber will receive the next email in the campaign. This can be formatted using Liquid date filters.
{{ subscriber.friendly_time_zone }}
This will insert the subscriber’s time zone abbreviation, e.g. PST, GMT, etc.
{{ now }}
This will insert the current time and date from your (the sender’s) time zone. It will look like this: 2017-01-17 18:26:33 +0000
To render it in a M-D-Y format, use this shortcode:
{{ now | date: "%a, %b %d, %y" }}
It will now appear like this: Tue, Jan 17, 17