I need to do email analytics, aim is to create an endpoint where when user sends an email to contact@mycompany.com, the email is processed and data in email is used for google analytics conversion.

main challenge I am facing is to create the endpoint, I am comfortable with PHP and client side js, but don't have idea about email tracking.

Help would be appreciated.

  • What data in the email is used in Google Analytics? How will you differentiate someone emailing your from a business card vs a contact form? Are you running any special campaign for a specific email. Spam email will screw up your analytics.
    – Anagio
    Nov 21, 2012 at 19:52
  • @Anagio... yes running google analytics for keywords and using conversion tracking for contact form on website. Will take care of spam emails with profile filters in analytics but need a way to log the data into analytics
    – Tarun
    Nov 22, 2012 at 4:28

1 Answer 1


We ran into this same exact issue a while ago. Here is the solution that worked for us. We use postfix for our mail servers. We setup a 2nd domain name to host our marketing email. This domain is setup with a catch all mailbox. When we send emails we send them with a different address and reply-to each time. (We have our own script for sending emails, which generates a random email (like craigslist) every time we send an email.

Then we wrote a small perl script that amavis/postfix calls whenever an email is replied to. This script triggers a php script which tracks the Action using Google Analytics for web. This is far more accurate than the solutions provided for email tracking by google, which only really track links in your email messages.

If setting up your own mail server is not an option, please consider MailGun. Mailgun was what we used for our first attempt at this and it worked flawlessley. What mailgun does is adds extra info to the mail header. That way mailgun automatically tracks opens, reads, replies, etc. If you really need that data in GA as we did, then you could have mailgun notify your server whenever there is an event. Mailgun just calls a webpage on your server and posts all the details about the event. Next you can have your server use the google analytics mobile api or the PHP api on GoogleCode to track the event.

You may want to keep mail analytics seperate from google analytics. Its hard to consolidate the data, and the cookies dont always match up. If its just your goal to track performance of your email campaigns, mailgun, mailchimp, and even sendgrid do good work with that. A service like ChartBeat can be used to mix data from the both.

  • Good answer, MailGun sounds like the dynamic phone number tracking scripts which post to your Analytics account when you get phone calls from campaigns using a unique number per campaign.
    – Anagio
    Nov 26, 2012 at 17:02
  • @Anagio, its similiar to what you can build with Voxeo or Twilio for phone apps. The guys at mailgun are amazing, rackspace just bought them, and I am hoping the service doesnt become overpriced. Mandrill is another option, but not as feature rich.
    – Frank
    Nov 26, 2012 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.