Simple way to implement Email Open Tracking

Posted By : Yasir Zuberi | 30-Jun-2016

Let’s first understand why Email Open tracking is important.
 
As you know each and every company spend time and money in generating leads of different types campaign leads, sales leads, subscription leads and much more. Based on the leads, send emails to thousands of email addresses. But how many of them actually gets viewed by the receiver of email.
 
It’s really important for the sender of email to know the view ratio of email out of all the emails sent, so that you may know whether people are really interested in your email or not.  
 
Here I will explain you, how simply you can apply email open tracking mechanism in your web-applications through pixel tracking.
 
You just need to add <img> tag in all the emails you sent. Now when receiver of email opens the email, browser makes the request to load that image which direct’s to your web-application. There you’ll receive request with the parameters you included in url and return a tiny 1x1 pixel image back to the browser. Most important part is person who receives  email doesn’t even know about all this processing.
 
Here’s a sample code written in groovy and grails, you may apply the same other web application frameworks as well.

//Let's consider this as your email open tracking url
 http://www.myWebApp.com/EmailTracking/trackEmailOpen/email.gif?param1=someValue&param2=someValue

According to the url, your  tag will be like


 
class EmailTrackingController {
   
    def trackEmailOpen() {

       System.out.println("Params received in request" + params);

	//you will get the params which you had included in your tracking url
	//Do some stuff, may want to save required info in your db.
    
        //Make sure you return the image.
        response.contentType = 'image/gif'
        //Using byte array from a 1×1 pixel transparent gif for performance and simplicity.
        def byte[] imageBytes = [71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 0, 0, -1, -1, -1, 0, 0, 0, 33, -7, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59]
        response.outputStream << imageBytes
        response.outputStream.flush()

    }
         
}

 

 

Few important points to make it work

  • Ensure email you are sending should be in html format
  • There are email readers which cache images in their own server after loading it once and Gmail is of them. Gmail loads the image only once from publically accessible url's and later calls gets served from their own cache proxy server.
  • In such cases, you need to rely only on your email opened as you cannot determine there how many times it's opened.

 

hope this helps out there.

Thanks

About Author

Author Image
Yasir Zuberi

Yasir is Lead Developer. He is a bright Java and Grails developer and have worked on development of various SaaS applications using Grails framework.

Request for Proposal

Name is required

Comment is required

Sending message..