Case Studies

How AdRoll sends & tracks emails in their Ruby app using the Mailgun API

Today’s post is written by Peter Clark, CEO of userfox (now AdRoll), an awesome new startup that is changing the way businesses communicate with their customers via email. They just launched a few weeks ago as you may have seen on Hacker News. In today’s post, Peter discusses what userfox does, how they’ve architected their app, and a little bit about how they are using Mailgun, including the code to do it! Enjoy.

Hi, I’m Peter, CEO of userfox. userfox helps companies send better, more effective, welcome emails. Today, most businesses welcome new customers with a singular “welcome to my product!” email.

The problem with that is people are busy. You forget that you signed up for services, you only remember services you need or love, and that generally doesn’t happen the second you register.

So userfox sends a sequence of emails: when you register, a few days later, a week later, later in the month, and so on. The industry calls this a “drip” sequence. These emails contain cool tips and tricks about your product, anecdotes about who your customers are and why they love you – and so on.

We do this really simply. In fact, its much faster to integrate userfox with your application than to send your one crappy welcome email. It’s a no brainer, right? simply paste a singular snippet of javascript into your footer – and voila.

How we architected our app

Framework: Ruby on Rails

Email automation & infrastructure: Mailgun

Database: MongoHQ for MongoDB

Testing: Citrus

How we use Mailgun

We’re an email marketing company. We’re not an infrastructure company, so we rely on Mailgun to do stuff that otherwise we’d have to build. Mailgun delivers all of our customers’ emails. The Analytics API of Mailgun powers the userfox analytics. Why should we re-create the wheel with this stuff, when Mailgun does such a rad job? Besides, have you tried managing an email server? Mailgun does God’s work….

Our basic implementation using Mailgun looks like this. We build the message data together:

And then queue it into a job via a REST post. Mailgun allows sending via SMTP but we prefer the flexibility and speed that comes with using the API. Our post looks like this.

Mailgun is really powerful when it comes to sending messages. But we also run all our analytics off of Mailgun. When a message is sent we want to know that it was delivered and what happened to it. Was it opened, clicked, reported as spam? Did the user unsubscribe (of course, this would never happen)? All this data can be sent to your app with webhooks. For instance, if you wanted to post to your database when a user clicks on a link you could do this:

This would tell you that a user has clicked on an email and give you information about who clicked it. You can do this for clicks, opens, unsubscribes, spam complaints, bounces, failures, and deliveries.

If you’ve got a business that needs to communicate with customers, give userfox a try. We’ve done the hard work for you.

“We’re able to ensure a better service for our marketers by using Mailgun. They count on us, and we count on Mailgun: and this relationship helps us maintain credibility with our customers.”

Paulius Milisauskas
115F513A-17CF-463E-999E-489BC063244D

Paulius Milisauskas

VP of Customer Operations

Related resources

Header Image - Best practices for 2018 emails

Best practices for 2018 emails

We all want better deliverability, but there are a few small things you need in place in order to...

Read more

Dribbble Case Study Article Image

How Dribbble improved connection & scalable sending with Mailgun

As the largest designer-oriented jobs community, Dribbble enables designers to display and share their work with peers and companies alike. As...

Read more

Header Image Email deliverability Finding a path to success video

Email deliverability: Finding a path to success

In a short video, learn about four key strategies that will help you ensure your emails have the...

Read more

Email icon

Get our news and tips every week

Keep me posted! Send me the newsletter – I expressly agree to receive the newsletter and know that I can easily unsubscribe at any time.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

See what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending
CTA icon