Tracking Replies in Mailgun (or any other email service)

We’ve recently been inundated with questions about how to track which email a recipient has replied to.  There are many use cases for needing to do this.  You may want to thread a conversation in your App or you may want to measure engagement.  The problem with relying on Mailgun Tags or Campaign-IDs is that these are not standard MIME headers so the receiving email service provider (ESP) may strip them out.

The proper way to do this is to use the Message-ID header because when a recipient replies to an email the Message-ID of the original email is included in the In-Reply-To header of the reply.

Let’s walk through an example.

When you send an email using Mailgun, Mailgun automatically creates a Message-ID and includes it in the response (you could also set your own custom Message-ID).

So if I send a message using the messages API:

curl -s -k --user api:key-3ax6xnjp29jd6fds4gc373sgvjxteol0 \
https://api.mailgun.net/v2/samples.mailgun.org/messages \
-F from='Excited User <me@samples.mailgun.org>' \
-F to='test <test@mailgunhq.com>'\
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'

Mailgun replies with:

"message": "Queued. Thank you.",
"id": "<20120502235917.29259.30669@samples.mailgun.org>"

You can see it in a screen shot of my terminal:

Now when I open that email in an email client and look at the email source headers, you can see that Message ID:

Ok, now let’s see what happens when I reply to that email.  I created a Route in Mailgun that posts my reply to a URL at Postbin.  Of course, Mailgun dutifully posts all of the headers.  As you can see below, the In-Reply-To header has the same Message-ID which you then can use to identify which specific email was replied to:

So that’s it, an easy way to track who’s replying to what.

Happy emailing!

Mailgunners

Mailgun Campaign Analytics: taking analytics beyond bulk email

Good news everyone!

Mailgunners just rolled out the most flexible Email Analytics product ever. This new shiny weapon gives you analytics normally reserved for those expensive email marketing services at a fraction of the cost. You don’t need that monkey on your back anymore! :P

Using it is straight forward.  Just create a Campaign ID through the Control Panel or API and tag your emails with that ID.

Creating a new Campaign with an ID:

curl https://api.mailgun.net/v2/mailgun.net/campaigns \
    -F name='Upgrade reminder' -F id='upgrade_reminder'

Sending a single message tagged with the campaign:

curl https://api.mailgun.net/v2/mailgun.net/messages \
    -F from='Developers ' \
    -F to='Bob Doe ' \
    -F subject='Please consider upgrading' \
    -F text='You will actually save money by upgrading' \
    -F o:campaign='upgrade_reminder'

We then start tracking and storing events down to the recipient level and roll up that data to provide insightful reports.

Let’s say you wanted to test the best day to send an upgrade offer to your users…just create a campaign for each day of the week.

For each Campaign ID, Mailgun will give you…

An overview for all the events that occurred with respect to the campaign:

A breakdown of the link performance and recipient domain performance to see which links recipients are clicking on and how the different recipient domains perform:

A timeline of the events during the day so you can see when recipients are interacting with your email (which you can use in conjunction with our delivery scheduling):

And an overview of geographic open and click performance:

Which you can drill down into for more detail:

Also, you can compare analytics across campaigns.  So let’s see which day was the best to send that upgrade offer:

Looks like Thursday is the winner… 

But what about all of those lost password emails we send out?  With Mailgun, you can get the same insights with your transactional emails since a campaign is just an ID you tag your emails with.

As expected, the open and clicks on the lost password emails are through the roof.  What if we added a subtle upgrade offer and link to the pricing page on those emails?

Transactional emails FTW! A 9% CTR to the pricing page with our lost password emails.

Mailgun Campaign Analytics are ideal for creating and testing user lifecycle and drip campaigns tied to certain usage patterns in your app.

Paul Stamatiou had a great post on the importance of this and a startup idea for user retention as a service. With Mailgun you could build this in a weekend.

What’s stopping you? :)

Can I get the data programmatically?

Absolutely. We have a robust API that we’ll devote a separate post to.  In the mean time you can check out the Campaigns API reference.

But what about traditional bulk email campaigns?

They are supported too! If you wish to do a more traditional mass campaigns at a fraction of the cost, simply do the following:

  • Create a mailing list, lets say “chicago@mycompany.com”
  • Add your recipients to it using our APIs
  • Send a message tagged with a campaign ID to “chicago@mycompany.com”
  • Profit!

Santa came to Mailgun early. Everyone gets new Logs.

Good news everyone!

Mailgunners are in the spirit of the season and wanted to give you a little holiday gift - new and improved Logs!  

So what’s new about the Logs?

- Account level log retention. Each paid account has data on at least 100,000 of the most recent messages in its Logs. For High Volume Plans, we can increase this number upon request. Previously, this was a dynamic number depending on the total messages going through Mailgun.

- Full text search. Search for domain, subject, or any text in the Logs. Previously, you could only search for full email addresses.

We have some more goodies coming out early in the new year, so stay tuned.

We hope you all have a wonderful holiday season.