Introducing MailJack: autogenerate querystring parameters that are appended to links in your emails

Hey All,

I just wrote a nifty gem and wanted to share(its one of my first). Wondering if anyone would be so kind as to tell me what they think and/or code review it.

MailJack - its like LoJack but for the links in your emails. The problem this solves is the ability to track click throughs in emails.

Basically, you specify what mailers you want to track links in, and what query string parameters you want to include. What’s cool is that you pass a Proc to each query string parameter that is evaluated at mail send time. Here’s what the configuration looks like

MailJack.config do |config|

config.mailers = [:user_notifier]

config.href_filter = /#{}/

config.encode_to = :utm_source

config.trackable do |track|

track.campaign = lambda{|mailer| mailer.action_name}

track.campaign_group = lambda{|mailer|}



So, mailers are your mailer classes that you want to track in underscore notation. Href_filter is a regex that will be used to match hrefs in the body of your email. This is useful so you don’t append parameters to links that go off your domain. Encode_to is optional and lets you specify a parameter where MailJack will stash a base64 encoded string of your parameters.

In the trackable block, you can specify any number of parameters that you want to appear in the appended query string.

So here’s an example. For the following mailer: UserNotifier#welcome_email, all links in that email will have the following appended


Actually, since we have the encode_to parameter specified, it would actually appear as:


Ok, I hope this is useful to others, as its definitely useful to me! And yes, feedback/code review is very much appreciated! :slight_smile: