Guides Amazon SES
How to set up a custom tracking domain on Amazon SES

By Alejandro Medina
Published
Short answer
By default, SES rewrites your links to an AWS tracking domain such as r.us-east-1.awstrack.me. To use your own subdomain, point t.example.com at the SES tracking domain of your Region (a CNAME for HTTP, or a CDN or proxy with a TLS certificate for HTTPS). Then set it as CustomRedirectDomain in the tracking options of your configuration set, with HttpsPolicy set to REQUIRE.
What does a custom tracking domain change?
When open and click tracking are on, SES changes each email a little:
- Opens. SES adds a 1x1 transparent image. When the mail client loads it, SES records an open.
- Clicks. SES replaces each link with a link to its own redirect server, which sends the reader on to your page and records the click.
Both point to an AWS tracking domain by default. Your reader hovers over "Read the post" and sees an awstrack.me URL that has nothing to do with you. A custom tracking domain replaces that host with your own subdomain, for example t.example.com. The tracking itself does not change. Only the host name in the links does.
You set it in three parts: the subdomain, the configuration set, and the event destination.
Part 1: Point a subdomain at SES
Pick a subdomain that does only this job, for example t.example.com. AWS recommends one subdomain for each Region that you send from. The parent domain must be verified in SES in the same AWS account.
Find the tracking domain of your Region in the SES tracking domains table. For us-east-1, AWS uses r.us-east-1.awstrack.me in its examples.
HTTP: one CNAME record
| Name | Type | Value |
|---|---|---|
t.example.com |
CNAME | r.us-east-1.awstrack.me |
This is enough for HTTP tracking links. AWS warns about the catch: if your email links to https:// pages and the tracking domain is HTTP only, readers can see a browser warning on click. Most newsletters today link to HTTPS pages, so set up HTTPS.
HTTPS: a CDN or a proxy with a certificate
SES does not hold a certificate for your subdomain, so something in front of it must. AWS describes CloudFront:
- Create a CloudFront distribution with the SES tracking domain of your Region as the origin.
- Forward the
Hostheader of the request to the origin. - Add a certificate that covers
t.example.com, and addt.example.comas an alternate domain name. - Point
t.example.comat the distribution: an alias record in Route 53, or a CNAME at another DNS provider.
A small reverse proxy that you run works too. This Caddy setup gets a certificate for the subdomain and passes each request to SES:
t.example.com {
reverse_proxy https://r.us-east-1.awstrack.me {
header_up Host {host}
}
}
Then point t.example.com at the IP address of the proxy with an A record. If your DNS is on Cloudflare, set that record to "DNS only", so the proxy can get its own certificate.
Check the subdomain
curl --head https://t.example.com/favicon.ico
HTTP/1.1 200 OK
x-amz-ses-region: us-east-1
x-amz-ses-request-protocol: https
x-amz-ses-region must be the Region you send from, and x-amz-ses-request-protocol must be https. If the Region is wrong, the subdomain points at the tracking domain of another Region.
Part 2: Set the domain on the configuration set
The custom domain belongs to a configuration set. Each email that you send with that configuration set uses it. With the AWS CLI, on an existing configuration set:
aws sesv2 put-configuration-set-tracking-options \
--configuration-set-name newsletter \
--custom-redirect-domain t.example.com \
--https-policy REQUIRE \
--region us-east-1
Or set it when you create the configuration set, in TrackingOptions:
{
"ConfigurationSetName": "newsletter",
"TrackingOptions": {
"CustomRedirectDomain": "t.example.com",
"HttpsPolicy": "REQUIRE"
}
}
The three values of HttpsPolicy:
| Value | Open links | Click links |
|---|---|---|
OPTIONAL (default) |
HTTP | The protocol of the original link |
REQUIRE |
HTTPS | HTTPS |
REQUIRE_OPEN_ONLY |
HTTPS | The protocol of the original link |
Use REQUIRE when part 1 gave you a working HTTPS subdomain.
Part 3: Turn on open and click events
The domain only matters if SES tracks opens and clicks. Add an event destination to the same configuration set, with the Open and Click event types selected. The destination can be SNS, CloudWatch, Firehose or EventBridge. The AWS page lists this as the third part of the setup.
Part 4: Send a test email
Send an email with the configuration set and a link in the body:
aws sesv2 send-email \
--from-email-address news@example.com \
--destination ToAddresses=you@example.com \
--configuration-set-name newsletter \
--content 'Simple={Subject={Data=Tracking test},Body={Html={Data="<p><a href=\"https://example.com/\">Open the site</a></p>"}}}' \
--region us-east-1
In the received email, the link starts with https://t.example.com/CL0/. Click it. You land on your page, and a click event arrives at the event destination.
Common problems
- The links still show awstrack.me. The email was not sent with the configuration set, or the configuration set has no custom redirect domain. Check the
--configuration-set-nameof the send. - Certificate error on click.
HttpsPolicyisREQUIRE, but the subdomain has no certificate. Finish the HTTPS part, or test withOPTIONALfirst. - The curl test shows another Region. The CNAME or the proxy points to the tracking domain of the wrong Region.
- Opens look too high or too low. Some mail clients load images on their own servers or block them, so opens are an estimate. Clicks are the better signal.
How BYOMailer handles this
In BYOMailer, a custom tracking domain is a setting of each sender identity. The instance runs a Caddy proxy that gets a certificate on demand for each tracking domain. You add an A record for your subdomain, click Check status, and BYOMailer checks the record, calls the proxy so it gets the certificate, and sets the subdomain on the configuration set of the identity with the HTTPS policy REQUIRE. The unsubscribe links can use a second subdomain, the custom link domain. The custom domains docs have the setup for both.
Questions
Do I need a custom tracking domain on Amazon SES?
No. Open and click tracking works without one. A custom domain puts your own subdomain in the tracking links instead of an AWS domain, so the links match your brand and the sender of the email.
Can I use a plain CNAME for HTTPS tracking links?
No. A CNAME to the SES tracking domain works for HTTP. For HTTPS, AWS describes a CDN such as CloudFront in front of the SES tracking domain, with a certificate for your subdomain. A reverse proxy such as Caddy with its own certificate does the same job.
What do the HttpsPolicy values mean?
OPTIONAL (the default) wraps open links in HTTP and keeps the protocol of each click link. REQUIRE wraps open and click links in HTTPS. REQUIRE_OPEN_ONLY wraps open links in HTTPS and keeps the protocol of each click link.
Does the tracking subdomain need its own SES verification?
Not if its parent domain is verified in the same AWS account. A verified example.com covers t.example.com.
How do I check that the domain points to the right Region?
Run curl --head https://t.example.com/favicon.ico. The response has the headers x-amz-ses-region and x-amz-ses-request-protocol. The Region must be the one you send from, and the protocol must be https.
Sources
- AWS: Configuring custom domains to handle open and click tracking
- AWS: SES API v2, TrackingOptions
- AWS General Reference: SES tracking domains
Products change. Spot a fact that's out of date? Open an issue in the code repository and I'll fix it.