# Merge tags

> Personalize campaign subjects and content with merge tags for names, email, custom fields and the unsubscribe link, and see how they differ from Temple.

Merge tags insert each recipient's own data into a campaign: their name in the subject, a custom field in the body, and their personal unsubscribe link. This page lists every tag, the syntax rules and how to preview the result.

## Available tags

| Tag | Replaced with |
| --- | --- |
| `{{first_name}}` | The contact's first name. |
| `{{last_name}}` | The contact's last name. |
| `{{email}}` | The contact's email address. |
| `{{unsubscribe_url}}` | The recipient's personal unsubscribe link. See [Unsubscribes](/docs/audiences/unsubscribes/). |
| `{{cf.<key>}}` | The value of a [custom field](/docs/contacts/custom-fields/), by its key. For example, `{{cf.company}}` for a field with the key `company`. |

Merge tags work in the campaign **Subject**, the HTML content and the plain-text version. They aren't replaced in the **From name**, **From email** or **Reply to**.

```html
<p>Hi {{first_name}},</p>
<p>Your {{cf.plan}} plan now includes scheduled sending.</p>
<p><a href="{{unsubscribe_url}}">Unsubscribe</a> from Acme emails sent to {{email}}.</p>
```

## Insert tags in the editors

- **Rich-text editor:** type `@` and choose a variable, or a custom field by its name.
- **Dragit editor:** use the merge fields menu, which lists First name, Last name, Email and your custom fields. The unsubscribe link is under the special links.
- **HTML editor** and the **Subject** field: type the tag.

## Syntax rules

- **No spaces inside the braces.** Write `{{first_name}}`. A tag with spaces, such as `{{ first_name }}`, isn't replaced and appears in the email as typed. This matters most for the unsubscribe link: the **Send** step's check accepts `{{ unsubscribe_url }}`, but only `{{unsubscribe_url}}` becomes a working link.
- **Tag names are not case-sensitive**, so `{{First_Name}}` works too. Custom field keys must match the stored key exactly, and keys are always lowercase, so write `{{cf.company}}`, not `{{cf.Company}}`.
- **Custom fields need the `cf.` prefix.** `{{company}}` isn't a merge tag and appears as typed.
- **Anything else in double braces stays as typed.** Emailit only replaces the tags in the table above.

## Missing values

When a contact has no value for a tag, the tag is replaced with nothing. There's no fallback syntax in campaigns: `{{first_name|"there"}}` isn't supported and appears as typed.

| Content | Contact with a first name | Contact without one |
| --- | --- | --- |
| `Hi {{first_name}},` | Hi Ada, | Hi , |
| `Hi there,` | Hi there, | Hi there, |

So either write copy that still reads well without the value, or make sure everyone has one. On the Contacts list, filter by **First name** with **is empty** to find contacts with a missing name.

## How values are rendered

| Field type | Rendered as |
| --- | --- |
| Text, Number | The stored value, for example `Acme` or `42`. |
| Date | `YYYY-MM-DD`, for example `1990-04-12`. |
| Boolean | `true` or `false`. |
| Select | The selected option. |
| Multi select | The options separated by commas, without spaces, for example `news,offers`. |

Values are inserted exactly as stored, without HTML escaping. If people can enter their own names, for example through a public sign-up form, check those values before you use them in HTML.

## Preview merge tags

- **Preview as contact**, in the **Preview and test** step, renders the subject and content with a real contact's data. Use it to check names, custom fields and empty values.
- **Test sends** fill `{{email}}` with the test address and leave names and custom fields empty. The unsubscribe link in a test doesn't unsubscribe anyone.

See [Test and schedule](/docs/campaigns/test-and-schedule/).

## Merge tags and Temple

Campaigns use their own merge tags. Templates sent through the [Email API](/docs/email-api/) and emails sent by [automations](/docs/automations/) use [Temple](/docs/templates/temple/), Emailit's template language, which looks similar but works differently:

| | Campaign merge tags | Temple |
| --- | --- | --- |
| Used in | Campaigns | API and SMTP sends with a template, automation emails |
| Data | The recipient contact | The `variables` you pass, or the automation run's contact and event data |
| Fixed set of tags | Yes, the five tags above | No, any variable you pass |
| Nested values | Only `cf.<key>` | Any path, such as `{{user.name}}` |
| Fallback values | No | Yes |
| Conditionals | No | Yes, `{{#if ...}}` |
| Unsubscribe link | `{{unsubscribe_url}}` | Not provided |

In Temple, a fallback goes after a pipe, for example `{{first_name|"there"}}`. If you save a campaign as a template and send it with the API, Temple fills its tags from the `variables` you pass. Pass `first_name` for `{{first_name}}`, a `cf` object for `{{cf.company}}` and your own `unsubscribe_url` if the content links to one. In automations, contact custom fields are available as `{{custom_fields.<key>}}`, not `{{cf.<key>}}`.

## Related

  - [Custom fields](/docs/contacts/custom-fields/): Define the fields you use in merge tags.
  - [Temple](/docs/templates/temple/): Variables, fallbacks and conditionals for API sends.

---
Source: https://emailit.com/docs/campaigns/merge-tags/
