【问题标题】:Pass link tags in links using Aws SES api使用 Aws SES api 在链接中传递链接标签
【发布时间】:2021-05-27 16:15:09
【问题描述】:

我正在使用 AWS SES api 发送电子邮件。我已使用配置集进行电子邮件跟踪,其中目标类型为空白;我使用的是 SES 默认域,并且我选择了点击事件。现在我想跟踪所有链接,但对某些特定链接执行操作。

为此,我尝试添加 ses:tags 属性所有标签,如此处文档中所述: 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>

但是这些标签既没有出现在链接中,也没有出现在 aws 发送的点击事件数据中。

更新

点击事件数据:

"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"
    }

注意:我没有在配置集中使用 Cloudwatch 作为事件目标。

有人可以指导我在这里做错了什么吗?

【问题讨论】:

    标签: amazon-web-services amazon-ses


    【解决方案1】:

    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

    我使用configset 将事件发送到SNS 主题并将我的lambda 订阅到SNS topic,结果如下:

    package main
    
    import (
        "fmt"
    
        "gopkg.in/gomail.v2" //go get gopkg.in/gomail.v2
    )
    
    const (
        Sender     = "sender@example.com"
        SenderName = "senders name"
        Recipient  = "recipient@example.com"
        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']}
    
    

    收到的电子邮件:

    【讨论】:

    • 感谢您的回答。但我需要邮箱中收到的电子邮件链接中的这些 ses 标签。它没有出现在那里。此外,当我单击链接时,我从 aws 获得了一个对象(有问题已更新)。在那个 linkTags 字段是空白的。那是我的问题。
    • @Amandeepkaur 我更新了答案,它仍然有效。如果您想发送电子邮件,您也可以使用直接 sdk,我尝试模仿文档而不是构建自己的文档,但这个想法仍然成立。我也得到了点击事件和相应的标签。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-31
    • 2018-12-12
    • 1970-01-01
    • 2016-01-19
    • 1970-01-01
    • 2011-01-01
    相关资源
    最近更新 更多