Using tags in transactional emails

A little known secret is that you can add tags to your transactional emails to group emails. Grouping your transactional emails is good for a couple of reasons. But first, what are tags?

What are tags?

Tags are text labels you can add to your transactional emails. These labels are a way to identify or group similar emails. This means you can add the label password-recovery to all password recovery emails and welcome to all welcome emails.

Why should you tag your emails?

Tagging your transactional emails help group them. You can then get performance insight for the different groups. What this means is you can:

  • Identify top performing groups by looking at the ones with the most opens and clicks.
  • Identify low performing groups and further understand why delivery, opens or clicks are poor. Is it because of the mail type? Design? Device? Or something else?
  • Do A/B tests to optimize conversion by creating different tags for different versions of the same email to see which ones perform best.

Ideas for tagging

Here are some ideas on how you can tag your transactional emails.

1. Tagging by message type

You can tag your transactional emails based on the message type, e.g. password recovery, welcome email, onboarding, order confirmation. This lets you track volume and performance of the various type of emails you send.

engage.so – analytics dashboard showing tags by email type

2. Tagging by customer

If you run a service that sends regular emails in newsletter form to customers, you can tag the emails with the customer email to know how your customers interact with your emails. This lets you identify top engaging customers by metrics like total opens and clicks.

engage.so – analytics dashboard showing tags by customer

3. Tagging by unique characteristics

If you send multiple versions of emails based on different characteristics like sending IP, language, design, send time, etc, you can tag your emails by these characteristics to analyse performance for optimisation.

How to tag your transactional emails

Most transactional email service provider support tags. Search your provider’s documentation for tags and you will see a guide on how it is implemented and how you can use them.

Here are some examples for some top email service providers:

Mailgun

Here is how to tag your emails if you use Mailgun. If you are sending through SMTP, simply add the header X-Mailgun-Tag. Here is an example with Nodemailer.

const transporter = nodemailer.createTransport({...})
const status = await transporter.sendMail({
  from: 'sender@bar.foo',
  to: 'receiver@foo.bar',
  subject: 'Updates for the week',
  html: '...'
  headers: {
    'x-mailgun-tag': 'weekly-updates'
  }
})

For multiple tags:

headers: {
  'x-mailgun-tag': [
    'weekly-updates',
    'ope@engage.so'
  ]
}

If you are using the send API, use the  o:tag  parameter.

const url = 'https://api.eu.mailgun.net/v3/domain.foo/messages'
await got.post(url, {
  username: 'api',
  throwHttpErrors: false,
  password: '...',
  form: {
    from: 'sender@domain.foo',
    to: 'receiver@foo.bar',
    subject: 'Updates for the week',
    html: '...'
    'o:tag': 'weekly-update'
  }
})

Amazon SES

Tags work in a different way in Amazon SES. Instead of just a label, AWS SES tags have a key and a value. They have the form:

key=value

If you are using the AWS SDK, use the Tags parameter. Here is a Javascript example:

const ses = new AWS.SES({...});
ses.sendEmail({
  Destination: {
    ToAddresses: ['jon@doe.com']
  },
  Message: {
    Body: {
      Html: {
        Charset: "UTF-8",
        Data: '<p>Yo. This is a test :)</p>'
      }
    },
    Subject: { Data: 'Hey' }
  },
  Source:  '"Awesome co" <hello@awesome.co>',
  Tags: [
    {
      Name: 'weekly-update',
      Value: 'week34'
    }
  ]
}, (err, data) => {
  console.log(data, err)
})

If you are sending through SMTP, use the X-SES-MESSAGE-TAGS tag in the form:

X-SES-MESSAGE-TAGS: tagName1=tagValue1, tagName2=tagValue2

Sendgrid

Sendgrid also has an interesting definition of tags. They call it categories. To send through SMTP, use the header X-SMTPAPI like this:

X-SMTPAPI: [category: 'weekly-update']

To send with the API, use the categories parameter.

Postmark

For Postmark, to send through SMTP, use the header X-PM-Tag, e.g:

X-PM-Tag: welcome-email

To send through the API, use the Tag parameter.
One important note though, Postmark only supports one tag per message.

Summary table

Identity Format Multiple tag support SMTP support API support
Mailgun Tag Single text Yes (up to 3) Yes Yes
Postmark Tag Single text No Yes Yes
Amazon SES Tag key=value Yes (up to 50) Yes Yes
Sendgrid Category Single text Yes (up to 100) Yes Yes

Viewing performance of your tags

Some email service provider will allow you view tag stats on the dashboard. For some others, you will have to get the stats through the API.

Mailgun – Tag analytics

If you use Engage for your transactional email analytics (you should!), the analytics section includes a tags page that shows you analytics for your tags and lets you filter messages by these tags. Sign up for free to get insight into your transactional email analytics.

engage.so – Tag analytics dashboard