Mailgun track unique opens

后端 未结 2 467
清酒与你
清酒与你 2021-01-13 15:13

Just tested mailgun through its API.

Everything is working fine.

Short: How to track unique opens for a specific mail through webhooks.

2条回答
  •  耶瑟儿~
    2021-01-13 15:31

    Ok I think I got an acceptable workflow - through the “custom variables”.

    You can define different values for each recipient, so you can send a unique id and then track that id on the open events. And just save one open for each sender or update the open time.

    My sending code (PHP):

    $result = $mg->sendMessage($domain, array(
                'from'    => 'foo@bar.de>',
                'to'      => 'recipient1@mail.de, recipient2@mail.de',
                'subject' => 'Hello %recipient.first% from %recipient.group%!',
                'text'    => 'Test of Mailgun',
                'html'    => 'It is so simple to send a message.
    Right?', 'o:tag' => array('test'), 'o:tracking-opens' => 'yes', 'v:my-custom-data' => '{"my_message_id": %recipient.id%}', 'recipient-variables' => '{ "recipient1@mail.de": {"first":"Recipient1", "group":"group1", "id":1}, "recipient2@mail.de": {"first":"Recipient2", "group":"group2", "id":2} }' ));

    Then in each event you get a response with the unique ids.

    Open event of first email:

    "user-variables": {
        "my-custom-data": "{\"my_message_id\": 1}"
    },
    

    Open event of second email:

    "user-variables": {
        "my-custom-data": "{\"my_message_id\": 2}"
    },
    

提交回复
热议问题