Sign inStart for $1

WritingPublished 2026-10-19Sources checked 2026-10-19By ColdAgentAI

Custom variables in cold email, step by step

A merge variable swaps a value from your lead list into your message. The skill is in the failure cases: give every variable a fallback or let the send stop, keep line breaks out of subjects, and render real rows before you send anything.

#What a merge variable does, and how it fails

Every mail tool that supports personalization works the same way in outline: your message holds a placeholder, your list holds a value for each contact, and the tool swaps one for the other at send time. Mailchimp describes it as a text-based identifier that corresponds to account data, replaced with the content stored in the matching audience field. The syntax differs between tools, but the same three things go wrong everywhere.

  • The empty value: the contact has no value, and the email reads "Hi ," or has a gap in a sentence. Mailchimp's help says that without a default value, a contact missing the data will see a blank space where the personalized content should be.
  • The wrong value: a typo in the placeholder or the wrong column. The same help page warns that if a merge tag is mistyped, contacts see the mistyped text instead of their personalized content.
  • The awkward value: a name in capitals, a full name in a first name slot, or a company name with a legal suffix that no person would say aloud.

Most of the work in custom variables is preventing these three, not inserting the first name. The sections below take them in order: fallbacks, naming and syntax, safe values, and testing.

#Fallbacks: what to show when a value is missing

A fallback is the text used when the contact has no value. There are two sound designs, and the right one depends on the variable.

  • A natural default for variables where a neutral word reads fine: "there" for a first name, "your team" for a company. Mailchimp's example is a default that makes contacts without a first name see "Hello Friend", which shows the idea even if you choose a plainer word.
  • No default, and stop the send, for variables the sentence cannot do without, such as the company name in a line that depends on it. Skipping one email is better than sending a broken one.

Other template languages draw the same line between missing and present. The Liquid template language documents a default filter that shows its value if the input is nil, false or empty. The detail to copy is that an empty string counts as missing, so a cell that holds only spaces should be treated as blank too.

A fallback that sounds odd is worse than a blank that stops the send. If "a wide range" does not fit the sentence for every contact, make the variable required instead.

#Syntax and names in ColdAgentAI

ColdAgentAI uses double curly braces. {{first_name}} inserts the first name, and {{first_name|there}} inserts the first name or, when the lead has none, the text after the bar. These details come from how the product renders messages:

  • The built-in names are first_name, last_name, company (also company_name), title and email. Any custom field on the lead can be used by its name, for example {{product_line}}.
  • Names are matched without regard to case, and a built-in name wins over a custom field with the same name.
  • A field name starts with a letter and holds letters, digits and underscores only. A custom field is limited to 50 fields per lead, a name of 64 characters, and a value of 2,000 characters.
  • A value that is empty or only spaces counts as missing. Values are trimmed before use.
  • A field with no value and no fallback does not produce an empty string. That email is not sent to that lead, and the send is recorded as failed with the name of the missing field.
  • A placeholder whose name is not valid, such as {{first-name}}, is not recognized and is left as written in the message, so scan the rendered text for double braces.

Spintax groups such as {Hi|Hello} are expanded first and leave {{variable}} placeholders alone, so you can combine both. A backslash before a brace or bar writes it literally. The spintax tool checks the braces and counts the variants.

#Keeping values safe in subjects and bodies

A value comes from a spreadsheet that someone typed or exported, so assume it can contain surprises: extra spaces, line breaks, capital letters, stray punctuation. The subject needs the most care, because it is a header. RFC 5322 says a header field body must not include CR and LF except when used in folding and unfolding, and treats an unstructured body as a single line of characters. A line break inside a merged subject is therefore a malformed header at best.

The same standard says each line of a message must be no more than 998 characters and should be no more than 78, which is a reason to keep long values, such as a pasted sentence in a custom field, out of subjects. ColdAgentAI collapses whitespace in a rendered subject onto one line and trims it, so a stray newline in a value cannot add a header line. Even so, clean the source: a value you would not want in a subject should not be in the list.

  • Trim leading and trailing spaces in every column before import.
  • Fix casing at the source: "MARIA" will be inserted as "MARIA".
  • Use the name the person uses, not a legal name, and a short company name without suffixes.
  • Keep custom fields to one short fact. A paragraph in a field is a signal you are writing the email in the spreadsheet.
  • Put a blank, not a guess, where you do not know the value.

#Test-render table: from row to rendered line

Before sending, render a sample that includes the awkward rows, then read the result. The test template is: Hi {{first_name|there}}, I noticed {{company}} sells {{product_line|a wide range}} online. Every lead below is invented and uses example.com addresses.

Lead row (input)Rendered resultVerdict
first_name Maria, company Harbor Lane Bakery, product_line wedding cakesHi Maria, I noticed Harbor Lane Bakery sells wedding cakes online.Pass
first_name empty, company Orchard Row Cafe, product_line emptyHi there, I noticed Orchard Row Cafe sells a wide range online.Pass, both fallbacks used; check "a wide range" fits this business
first_name only spaces, company Pine Street Books, product_line used booksHi there, I noticed Pine Street Books sells used books online.Pass, spaces count as blank
first_name DEV, company Quay Print, product_line postersHi DEV, I noticed Quay Print sells posters online.Fix the data: the capitals are inserted as stored
first_name Sam, company missing, product_line candlesNo email. The send fails and names the missing field "company".Correct stop; add the company or drop the row
Template typo: {{first-name}} instead of {{first_name}}Hi {{first-name}}, I noticed ... (placeholder left as written)Fail; search the output for double braces and fix the name

Read the verdict column as a checklist of what to look for in your own sample: missing values, fallbacks that do not fit, odd casing and placeholders that survived into the output. The rendered text is the only thing the recipient sees, so it is the only thing worth reviewing.

#A pre-send routine

  1. List every variable the message uses, and mark each one as required or as having a fallback.
  2. Check the column for each variable: sort it, then read the first and last rows, where blanks and stray text collect.
  3. Render at least one row from every segment, plus the three worst rows you can find, and read every result.
  4. Search the rendered subject and body for double braces, double spaces and a comma at the start of a sentence.
  5. Confirm that required variables cannot be empty for any contact you are about to send to, and remove the contacts who lack one.
  6. Send a first small batch to addresses you control and read the real messages in a mail client.

For choosing which facts deserve a variable in the first place, see personalization at scale, and for lines written from a sourced note, AI-written opening lines.

#Frequently asked questions

What happens if a lead has no first name?

If your template says {{first_name|there}}, the email reads "Hi there". If it says {{first_name}} with no fallback, the email is not sent to that lead and the send is recorded as failed with the field name.

Can I use my own columns as variables?

Yes. Any custom field on the lead works by name, written as {{product_line}} for a field called product_line. Names use letters, digits and underscores and start with a letter.

Why not insert a whole sentence from a spreadsheet cell?

Long values are hard to review and easy to get wrong, and in a subject a line break would be a malformed header under RFC 5322. Keep each field to one short fact and write the sentence around it.

How do I catch a mistyped placeholder?

Render a sample and search the output for double braces. A name that is not valid, such as one with a hyphen, is left as written rather than flagged, and Mailchimp's help warns of the same effect with a mistyped tag in its own syntax.

#Sources

  1. Getting Started with Merge Tags, Mailchimp HelpRead 2026-10-19. Merge tags replaced with stored content; no default means a blank space; a mistyped tag shows as typed; default value example "Hello Friend"; preview and test before sending.
  2. default filter, Liquid template languageRead 2026-10-19. The default filter shows its value when the input is nil, false or empty.
  3. RFC 5322, Internet Message FormatRead 2026-10-19. Header field bodies must not contain CR or LF except in folding; unstructured bodies are single lines; lines must be at most 998 and should be at most 78 characters.

In ColdAgentAI

Multi-step campaigns that stop on their own when a lead replies or bounces.

Free tools for this topic: