Sub topic 6
Personalising Subject Lines and Preheaders
This chapter assumes you can send a campaign, know what contact fields are, and have already inserted merge tags with fallback values in a message body. Here you apply those skills to the two pieces of text a recipient reads before opening: the subject line and the preheader.
Why the subject line and preheader are different from the body
The subject line is the headline shown in the inbox list. The preheader is the short preview text shown next to or under it. Together they decide whether the email gets opened.
These fields behave differently from the body in four ways:
- They are plain text. You cannot use HTML, images, or styled blocks. Only text and merge tags work.
- They are short. Mobile clients often cut a subject at around 30 to 45 characters. Desktop clients show more, but you cannot rely on it.
- They are seen without any context. A broken tag in the body sits inside a designed email. A broken tag in the subject sits alone in a list of other messages.
- They are often tested last. Many platforms preview the body by default and make you open a separate view for the subject.
Because of this, mistakes here cost more than mistakes in the body, and you must write defensively.
Inserting merge tags in the subject line
The syntax is the same as in the body. Most platforms let you type the tag directly into the subject field, or offer a "personalise" button that inserts it.
{{ customer.first_name | default: "there" }}, your order has shippedA contact named Sam sees "Sam, your order has shipped". A contact with no first name sees "there, your order has shipped". That second result is awkward, and it shows the main problem with subject personalisation: a fallback that works in a greeting often reads badly at the start of a subject line.
Tag and field names vary by platform. Mailchimp uses *|FNAME|*, and some platforms use [[first_name]] or %%first_name%%. The logic is the same: a tag is replaced with a field value at send time.
Writing a subject that works with and without the tag
Treat the merge tag as optional. Write a subject that still reads well when the name is replaced by a fallback or removed. There are two common approaches.
- Put the tag mid-sentence with a neutral fallback. For example, "Your next step, {{ customer.first_name | default: "friend" }}" ends with the name, so a fallback reads as a normal word.
- Use conditional logic to change the whole phrase. If the field is present, include the name. If not, use a version of the subject written without it.
The second approach gives better results, because the fallback is a complete sentence and not a patched one. It needs a platform that supports conditionals in the subject field, which not all do.
{% if customer.first_name != blank %}
{{ customer.first_name }}, your order has shipped
{% else %}
Your order has shipped
{% endif %}Check one detail first. Conditional tags often add line breaks around the output. Some platforms trim these in the subject field, and some do not. If yours does not, use whitespace-control syntax such as {%- and -%} where the platform supports it, or move the logic into a single computed field.
{%- if customer.first_name != blank -%}{{ customer.first_name }}, your order has shipped{%- else -%}Your order has shipped{%- endif -%}Personalising beyond the first name
The first name is the most common field and the most overused. Subscribers have seen it often enough that it carries little weight on its own. Other fields can do more:
| Field type | Example subject | Main risk |
|---|---|---|
| Plan or tier | "Your Pro plan renews on 3 December" | Wrong tier shown if data is stale |
| Location | "Events near {{ customer.city }} this weekend" | Missing or misspelled city |
| Last purchase | "Accessories for your {{ last_product }}" | Product names are long and can be truncated |
| Date or number | "Your 14-day trial ends tomorrow" | Calculated values must be correct at send time |
| Behaviour | "You left something in your basket" | Can feel intrusive (see the privacy chapter) |
The rule is that personalisation should add information the reader values. A name adds recognition. A renewal date adds something to act on.
Preheaders
The preheader is the text that follows the subject in the inbox. If you do not set one, most clients take the first text they find in the email body, which is often "View in browser" or an unsubscribe note. That wastes the space.
Most platforms have a separate preheader field. Merge tags and conditionals work in it just as they do in the subject.
{% if customer.plan == "pro" %}
Priority support is included in your plan.
{% else %}
See what Pro could add to your account.
{% endif %}Treat the subject and preheader as one message. The subject carries the main point and the preheader adds a detail or a reason to open. Do not repeat the same words in both. Also avoid putting the same personalised value in both, because it uses the limited space twice.
Length limits for preheaders
Clients display roughly 40 to 130 characters of preheader depending on device and layout. Put the important words first. If the preheader is shorter than the space available, some clients fill the rest with body text. You can prevent this with hidden padding characters in the template, but that is an HTML technique outside this chapter, and your platform may already handle it.
Failure modes
Subject-line errors are visible and cannot be recalled after sending. These are the ones to check for.
- Raw tags shown to the reader. A tag that fails to resolve may print as
{{ customer.first_name }}or*|FNAME|*. This happens when the field name is misspelled or the platform does not support the syntax in that field. - Empty values. Without a fallback, "Hi , your order has shipped" is sent, with a stray space and comma.
- Placeholder data. Contacts who typed "test", "n/a", or their email address into the first-name field get "test, your order has shipped".
- Wrong case. Names imported in capitals or lower case, such as "SAM" or "sam", look wrong in a subject. Fix the data or apply a filter such as
capitalize. - Truncation. A long value, such as a full product name, pushes the key words past the cut-off point.
- Spam filters. Subjects with many tags, excess punctuation, or all-capital words can raise spam scores. Personalisation alone does not cause this, but a stray capitalised name can contribute.
{{ customer.first_name | default: "friend" | capitalize }}, your order has shippedBe careful with the order of filters. capitalize on an empty value returns an empty value, so the default filter should come first, as shown above. Also, default in Liquid treats an empty string as missing only in some implementations, so test with an empty string and with a missing field, not only one of them.
Checking the rendered subject in code
You can check your own logic outside the platform by rendering it with Jinja2, which has similar syntax. This is useful to confirm what a template produces for a list of awkward inputs before you rely on the platform to handle them.
from jinja2 import Environment
env = Environment()
template = env.from_string(
"{{ first_name | default('there', true) | capitalize }}, your order has shipped"
)
for value in ["sam", "", None, "SAM"]:
print(repr(value), "->", template.render(first_name=value))The true argument tells Jinja2 to treat empty and false-like values as missing. Without it, an empty string would pass through and the subject would start with a comma. This corresponds to the Liquid behaviour mentioned above, and it is a good reminder to test empty values separately from missing ones.
A pre-send checklist
- Every tag name in the subject and preheader matches a real field.
- Each tag has a fallback, or a conditional branch that omits it.
- The subject reads correctly with the fallback in place.
- The most important words appear in the first 40 characters.
- The preheader is set and does not repeat the subject.
- You tested at least three contacts: complete data, empty fields, and unusual data such as capitals or very long values.
Exercise
A subject line is written as "{{ customer.first_name | default: "there" }}, your order has shipped". Why might this still read badly for contacts with no first name, and what is a better design?
Show answer
The fallback produces "there, your order has shipped", which sounds like a broken greeting because "there" only works after "Hi". A better design is a conditional: if the first name is present, use "Sam, your order has shipped", otherwise use "Your order has shipped". The fallback is then a complete sentence instead of a patched one.
Exercise
A preheader is left empty and the email begins with "View this email in your browser". What does the recipient see in many inboxes, and how do you fix it?
Show answer
Many clients take the first body text as the preview, so the recipient sees "View this email in your browser" next to the subject. Fix it by setting the preheader field explicitly, with a short line that adds to the subject and puts the key words first.