Tag syntax: writing a tag by hand and giving it a fallback
A tag is a placeholder you put in an email that fills in with that contact's own data when the email is sent. Most of the time you don't type one, you copy it from the Tags panel in the editor and paste it in.
This article is for the times you do type one, and for working out why a tag came out blank or printed itself instead of filling in.
What a tag looks like
A tag is an attribute key wrapped in double curly braces:
{{contact.firstname}}
The key has 2 parts, separated by a dot: the group the attribute belongs to, then the attribute itself. contact.firstname, contact.loyalty_balance, voucher.code, email_recipient.unsubscribe_url. The Tags panel is grouped the same way, so the heading you pick from is the first half of the key.
Spaces inside the braces don't matter. {{contact.firstname}} and {{ contact.firstname }} are the same tag. The panel inserts the tight version.
Giving a tag a fallback
If a contact has no first name, {{contact.firstname}} fills in with nothing, and "Hi ," goes out. A fallback is the text we use instead when the attribute is empty for that contact:
Hi {{contact.firstname | fallback: there}},
A contact with a first name gets "Hi Sarah,". A contact without one gets "Hi there,".
The fallback goes after a pipe, and everything after fallback: is the text, with the spaces around it trimmed off. There's no button for this. You paste the tag from the panel and then type the pipe and the fallback yourself.
What happens when a tag doesn't fill in
Three things can happen, and telling them apart is how you find out what went wrong.
- The tag fills in. We recognise the key, and this contact has a value for it.
- The tag comes out blank. We recognise the key, but this contact has no value for it, and the tag has no fallback. This is what a fallback is for.
- The tag prints itself. The recipient sees
{{contact.frstname}}, braces and all. That means we didn't recognise the key at all. It's usually a typo, or a tag that doesn't apply where you pasted it.
That last one is deliberate. We'd rather show you the tag than quietly replace it with nothing, because nothing is exactly what a contact with no first name would get, and then you'd have no way to tell the 2 apart.
A tag with a fallback prints the fallback in both of the failing cases, so a fallback covers a typo as well as an empty value. That's convenient, and it also means a broken tag can look like it's working. Check a tag once without its fallback if you want to be sure the key is right.
Tags for your own custom attributes
Custom contact attributes get tags too, under contact., built from the attribute's name rather than the label you see on the contact profile. The 2 are often different, so copy the tag from the Tags panel rather than assembling it from what's on screen.
If the attribute is a dropdown, the tag fills in with the label of the chosen option, not the value stored behind it. Attributes that hold an uploaded file or media don't get a tag.
The unsubscribe link is a tag as well
{{email_recipient.unsubscribe_url}} is the link a contact uses to unsubscribe. You'll find it in the Tags panel under Email recipient, as Unsubscribe link.
Unless the email's subscription type is functional, it needs the unsubscribe link or the Subscription preferences link, and we'll stop you sending without one. Paste the tag as it comes from the panel: a tag with a fallback added doesn't count for this check.