Reputation: 1025
I am using AWS SES api to send emails. I have used configuration set for email tracking in which the destination type is blank; I am using SES default domain and I have selected click event. Now I want to track all links but perform action to some particular links.
To do this I tried adding ses:tags attribute all tags as described in the documentation here: sending metrics link
<a ses:tags="product:book;genre:fiction;subgenre:scifi;type:newrelease;" href="http://www.amazon.com/…/">New Releases in Science Fiction</a>
But these tags neither show up in the link nor in the click event data sent by aws.
UPDATED
Click event data:
"click" : {
"ipAddress" : "1.1.1.1",
"userAgent" : "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0",
"link" : "http://www.facebook.com",
"linkTags" : "",
"timestamp" : "2021-02-11T03:32:54.848Z"
}
NOTE: I am not using Cloudwatch as event destination in configuration set.
Can someone guide me what am I doing wrong here?
Upvotes: 0
Views: 2348
Reputation: 9625
It's only possible to track clicks in HTML emails.
How can I monitor the opens, clicks, and bounces from emails that I send using Amazon SES?
Sending email using the Amazon SES SMTP Interface
I used configset
to send the events to SNS
topic and subscribed my lambda to SNS topic
, below are the results:
package main
import (
"fmt"
"gopkg.in/gomail.v2" //go get gopkg.in/gomail.v2
)
const (
Sender = "[email protected]"
SenderName = "senders name"
Recipient = "[email protected]"
SmtpUser = "username"
SmtpPass = "password"
ConfigSet = "Engagement"
Host = "email-smtp.eu-central-1.amazonaws.com"
Port = 587
Subject = "Amazon SES Test (Gomail)"
HtmlBody = "<html><head><title>SES Sample Email</title></head><body>" +
"<h1>Amazon SES Test Email (Gomail)</h1>" +
"<p>This email was sent with " +
"<a ses:tags='product:book;genre:fiction;subgenre:scifi;type:newrelease;'href='https://aws.amazon.com/ses/'>Amazon SES</a> using " +
"the <a ses:tags='product:email;genre:test;subgenre:custom;type:gomail;'href='https://github.com/go-gomail/gomail/'>Gomail " +
"package</a> for <a href='https://golang.org/'>Go</a>.</p>" +
"</body></html>"
TextBody = "This email was sent with Amazon SES using the Gomail package."
Tags = "genre=test,genre2=test2"
CharSet = "UTF-8"
)
func main() {
m := gomail.NewMessage()
m.SetBody("text/html", HtmlBody)
m.AddAlternative("text/plain", TextBody)
m.SetHeaders(map[string][]string{
"From": {m.FormatAddress(Sender, SenderName)},
"To": {Recipient},
"Subject": {Subject},
"X-SES-CONFIGURATION-SET": {ConfigSet},
"X-SES-MESSAGE-TAGS": {Tags},
})
d := gomail.NewPlainDialer(Host, Port, SmtpUser, SmtpPass)
if err := d.DialAndSend(m); err != nil {
fmt.Println(err)
} else {
fmt.Println("Email sent!")
}
}
click event
:
In [29]: click_event['click']
Out[29]:
{'timestamp': '2021-02-26T10:44:00.606Z',
'ipAddress': 'xx.xx.xx.xx',
'userAgent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15',
'link': 'https://aws.amazon.com/ses/',
'linkTags': {'product': ['book'],
'subgenre': ['scifi'],
'genre': ['fiction'],
'type': ['newrelease']}}
..
In [38]: click_event['mail']['tags']
Out[38]:
{'ses:operation': ['SendSmtpEmail'],
'ses:configuration-set': ['Engagement'],
'ses:source-ip': ['xx.xx.xx.xx'],
'ses:from-domain': ['example.com'],
'genre': ['test'],
'genre2': ['test2'],
'ses:caller-identity': ['ses-smtp-user']}
open_event
In [41]: open_event1['mail']['tags']
Out[41]:
{'ses:operation': ['SendSmtpEmail'],
'ses:configuration-set': ['Engagement'],
'ses:source-ip': ['xx.xx.xx.xx'],
'ses:from-domain': ['example.com'],
'genre': ['test'],
'genre2': ['test2'],
'ses:caller-identity': ['ses-smtp-user']}
Received email:
Upvotes: 0