Listrak's Dynamic Content solution allows marketers to dynamically change a portion of an email based on what criteria a contact meets (or doesn't). As a result, the subject line of your email may need to be updated to reflect this differing content. Dynamic Subject Lines utilizes Liquid coding to create dynamic subject lines.

Below you will find instructions on how to set up dynamic subject lines and specify a default. You will also find examples of liquid code to create dynamic subject lines.

If you unfamiliar with Liquid, learn more about the coding language.

If you are ready to create your code, learn more about:


The Elements of Liquid

If you are unfamiliar with Liquid Coding, the definitions below are going to be helpful when getting started.

What is Liquid?

Liquid is a template language that allows the loading of dynamic data into an element of an email or website. This coding language is used in many places, including Shopify, who originally created it.

What is an Object?

An object is a variable in liquid that can be used as part of the conditional logic to determine what version a contact should receive and can also be used as personalization in the subject line. In Listrak these variables come from your profile fields.

Hi {{contact.profile.contactinfo.firstname}}

What is a Liquid Filter?

A filter in liquid is very different than a filter in Listrak's system. A liquid filter is used to modify the appearance of an object variable. For example, a liquid filter can capitalize a variable or transform the text so that is appears in all uppercase.

Hi {{contact.profile.contactinfo.firstname | capitalize}}

What is a Tag?

A tag is used to control what a contact will and won't see when using objects and filters. A tag begins with {% and ends with %}. Any input between these two will not visually appear. These tags can be used to format the results, such as making a value capitalized.

{% This information will not appear %} but this will!

What is Liquid's Logic?

Liquid allows the use of if/els logic to determine which version of content (in this case subject line) a contact would receive. The if/els logic can evaluate an object's value. For example, send different subject lines based on a contact's loyalty tier or change a contact's subject line if the last browsed category profile field contains a specific word.


Understanding Liquid Logic

When creating a dynamic subject line using liquid logic, you will create two main components 1) the default option and 2) the if/els statement that specifies the other subject line options.

The default option is the subject line a contact will receive if they do not meet the criteria set up in the if/els statement. This fallback is used to ensure all contacts receive an email that contains a subject line. The default option is created in Listrak's standard subject line in the message creation experience.

The if/els statement is used to determine which version of a subject line a contact should receive. The if/els statement evaluates an object for a specific value and then specifies the result that should happen when the value is found.

Operators are used to determine what criteria needs to be found in the object in order for someone to receive the specified subject line.

💡 The values used in connection with these operators should be enclosed in quotation marks.

Operator

Syntax

Equals

==

Does Not Equal

!=

Greater Than

>

Less Than

<

Greater Than or Equal To

>=

Less Than or Equal TO

<=

Or

or

And

and

Contains

contains

For example, the if/els logic could evaluate the variable of favorite season. In the table below you will see the value the statement is looking for and the result (subject line) that would appear. In this example, an operator like equals can be used to specify the different seasons.

Value

Result

Spring

Fresh looks to put a spring in your step.

Summer

Cool looks to soak up this summer.

Fall

Looks you'll fall for!

Winter

Cozy looks to keep you warm all season long.

Blank or value that is not specified above

Looks you'll be loving all year long.

When using data such as checkbox and radio button data, the system will look for specific values based on if the values are selected.

Data Type

Selected

Not Selected

Radio Button

1

0

Checkbox

on

off

⚠️ These values are stored as text and must be enclosed in quotation marks

{% if contact.profile.ldloyaltytestinfo.interestedinmore == "1" %}
Thank you for your interest! We will be in touch soon.
{% endif %}


Filtering in Liquid

Filtering in Liquid provides a way to change the way an object appears. Common types of filters include: show the whole output in uppercase, capitalize the first letter, add a specific value to the beginning, or adding a specific value to the end. Filters are often used when the object appears in the subject line. Below you will find a few examples of common filters.

Append a pipe and the specific action that should be taken after the field name to add a filter to the object.

Capitalize:

{{contact.profile.contactinfo.firstname | capitalize}}

Uppercase:

{{contact.profile.contactinfo.firstname | upcase}}

Downcase/Lowercase:

{{contact.profile.contactinfo.firstname | downcase}}

Learn more about filters available in Liquid.


Creating a Default Subject Line

When creating a dynamic subject line, you will always be required to specify a default subject line. This subject line will be sent to anyone who does not meet any of the logic specified.

The default subject line is created in the message builder. Navigate to: Messages > Email New Broadcast Email.

Default subject lines can include personalization, such as a contact's first name, stored in a profile field. You can use the Personalization Control Panel to create the formatted tag.

💡 If your email contains dynamic content, the default subject line should correspond to your last variation.


Using Profile Information in Dynamic Subject Lines

When creating the dynamic versions of your subject line, the personalization fields are a critical element. Profile fields serve two purposes: 1) personalize the content of a subject line and 2) determine which contact should receive each version of a dynamic subject line.

After you click Add Dynamic Subject Line in the New Email Broadcast experience, the dynamic subject line experience will open. Here you can create your If/Els statements using Liquid coding.

To include a Listrak profile field object in your code, the drop-down in the top right will contain all profile fields for your current list.

💡 Use the search function to quickly find a specific profile tag.

Selecting a tag will add it to the code builder on the left side. Learn more about how these tags are written below.

In the code blocks below are the common layouts you may find when adding a profile field into Liquid. Here are a few pointers to help understand the syntax.

  • All liquid objects are enclosed in curly brackets

  • All profile fields begin with contact.profile

  • Next the field group name and field name will be referenced

  • If these names contain a space or special character they will be enclosed in square brackets and quotation marks

  • If no space exists, the names will be separated by a period

  • Dashes and hyphens are not considered special characters

No space in either name:

{{contact.profile.fieldgroupname.fieldname}}

{{contact.profile.contactinfo.firstname}}

Space in one name:

{{contact.profile["field group with space"].fieldname}}

{{contact.profile["fa alerts"].couponexpiration}}

Space in both names:

{contact.profile["field group with space"]["field name with space"]}}

{{contact.profile["fa alerts"]["product sale price"]}}

Creating a Single If Statement

While every dynamic subject line requires a default value, the number of potential subject lines may depend on your goal. You may have only one additional subject line that may appear. This is especially useful when the object you are evaluating is a profile field created as a checkbox or radio button. In this case, only two options are available. One of these objects will become your default value and you can use the if statement to specify the subject line for the second option.

{% if contact.profile.ldloyaltyinfo.ismember == "on" %} 
Time to get the VIP experience started! The exclusive sale starts now!
{% endif %}

💡 Key Coding Components

  • The tag begins with { % if... % } and ends with { % endif %}

  • The object whose value is being compared to comes next

  • The object does not need to be enclosed in curly brackets

  • The operator is used to specify the compared values and comes after the object

  • The dynamic subject line that will be received if a contact meets the criteria appears before the closing tag


Creating an If/Els Statement

An If/Els statement allows you to specify multiple potential subject lines by specifying multiple options for the value a contact should meet. An If/Els statement is useful when a text field operator is being used and multiple text inputs are possible.

{% if contact.profile.customerprofile["loyalty.currenttierlevel"] == "Bronze" %}
Bronze VIP members earn 2x the points during our VIP sale.
{% elsif contact.profile.customerprofile["loyalty.currenttierlevel"] == "Silver" %}
Silver VIP members earn 3x the points during our VIP sale.
{% elsif contact.profile.customerprofile["loyalty.currenttierlevel"] == "Gold" %}
Gold VIP members earn 4x the points during our VIP sale.
{% endif %}

💡 Key Coding Components

  • The tag begins with { % if... % } and ends with { % endif %}.

  • Additional options begin with { % elsif

  • Multiple objects can be used in the tag, or one object can be compared multiple times

  • The object does not need to be enclosed in curly brackets

  • The operator is used to specify the compared values and follow each object in the if or elsif statement

  • Subject line options are added between elsif statements

📌 In the example above, the subject line dynamically updates the type of VIP and amount of points earned based on the tier in the Current Tier Level profile field in Listrak. If a contact does not meet one of these values, they will receive the default subject line set in the New Broadcast Message screen.


Evaluating Multiple Fields or Conditions

In the loyalty example above, a single field is evaluated multiple times to search for a specific value. However, you may want to evaluate multiple fields to determine if a contact has at last one attribute, or you may want to accept multiple values in a single field.

Multiple values can be connected with the and and or operator. Operators will be evaluated from left to right.

{% if contact.profile.customerprofile["loyalty.currenttierlevel"] == "Bronze" or contact.profile.customerprofile["loyalty.currenttierlevel"] == "Silver" orcontact.profile.customerprofile["loyalty.currenttierlevel"] == "Gold" %}
VIPs earn extra points in our sale starting TODAY!
{% endif %}

📌 In the example above, the subject line is dynamically updated if a contact has one of three values in their loyalty tier profile field. If a contact has the value of Bronze, Silver, or Gold, they will receive the dynamic subject line. Any other value will receive the default subject line.

These and or conditions can also be used in elsif statements.

{% if  contact.profile.ldloyaltytestinfo.loyaltytier == "Bronze" or contact.profile.ldloyaltytestinfo.loyaltytier == "Silver" %}
VIPs earn extra points in our sale starting TODAY!
{% elsif contact.profile.ldloyaltytestinfo.loyaltytier == "Gold" %}
Gold VIP members earn 4x the points during our VIP sale.
{% endif %}

Did this answer your question?