Using tags in transactional emails
Tags allow you to group your transactional emails so that you can get performance insight across the different groups. In this piece, we explore what tags are, why they are important and how you can use them.
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.
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.
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: '[email protected]',
to: '[email protected]',
subject: 'Updates for the week',
html: '...'
headers: {
'x-mailgun-tag': 'weekly-updates'
}
})
For multiple tags:
headers: {
'x-mailgun-tag': [
'weekly-updates',
'[email protected]'
]
}
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: '[email protected]',
to: '[email protected]',
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: ['[email protected]']
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: '<p>Yo. This is a test :)</p>'
}
},
Subject: { Data: 'Hey' }
},
Source: '"Awesome co" <[email protected]>',
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.
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.