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.
Home
The Mailgun Resource Center
Case studies
How userfox sends & tracks emails in their Ruby app using the Mailgun API
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
VP of Customer Operations