Codementor Events

Email Tracking - how and benefits

Published Sep 10, 2019
Email Tracking - how and benefits

Why Email tracking?
Email is an old way of communication but still it is considered as one of the best way of communication. Email is still the right medium to communicate with your customers. There are numerous reason for this :

Collecting feedback
Targeted personalized notifications
Efficient way to promote any product or service online
Efficient way of One-To-Many communication

You send out an important email like any personalized email, some kind of promotion etc.) and waiting to hear back soon, but nothing comes up. You start to wonder whether the email has been read or not. Now, you must be wondering is there any way to know whether recipient has read you email or not? Or is it possible to track an email or not?

Yes, there are many ways to get to know whether recipient has read your mail or not.

What is Email tracking ?
Email tracking is something that lets you know the effectiveness or your promotion/campaign/notification. It works in background without interrupting the receiver. Before describing how email tracking works, let’s see what we can achieve using email tracking.

We can get to know when and on which device does recipient opened the email and know exactly when to follow up.
We can also get to know how many times the email has been opened.
You’ll start writing better emails.

Email (electronic mail) is digital message that area transmitter from sender to one or more receipts. Email works in an asynchronous way, as both sender and receiver need not to be online at the same time. Basically, email has two part header and body. The header contains details like sender address, description of the mail, receiver’s email address and more.

Although, sending an email is very easy but it is difficult to track it’s status. There are many approaches available like read receipt, image-tag mechanism amongst others but none of them solves the problem 100% for you. Let’s see how some of these work.

Read-Receipt Mechanism:
This is a kind of request to the recipient’s email server to send you a notification about the delivery and read status of an email that you have sent. A read-receipt is returned from the receiver to the sender when email is successfully opened by the receiver. There are few mail server/client who support this feature like Microsoft Outlook.

This can be implemented by inserting one or more of the following line into email header: X-Confirm-Reading-To, Disposition-Notification-To, Return-Receipt-To.

Below is an sample code to show how to add the Header in email request.

Example:

var message = new MailMessage("sender@sender.com", "receiver@receiver.com");
message.Subject = "Read receipt test";
message.Body = "Read receipt test.";
//add the header that requests the user to send a receipt
message.Headers.Add("X-Confirm-Reading-To", "sender@sender.com");
var client = new SmtpClient("smtphost.com");
client.Send(message);

In Microsoft outlook client, we can also add these request from option tab before sending the email.

In this case when receiver double clicks the email, he can choose to send a read receipt or not. Only few mail server support this mechanism.

So here is another way to overcome this limitation another way of email tracking image-tag mechanism.

Image-Tag Mechanism:
This method is better than the read-receipt as it can be applied independent of the mail server but still there are some limitation and few pre-requisite for this mechanism. This method will not work if the user has disabled the image on receiving side but by default it’s enabled in most of the email client. And pre requisite is that email body has to be in HTML format.

So, the idea is very simple, and image tag is embedded in the email body which has source pointing to an external resource(example a restful web service like http://external-resource:8080/email-tracker/email-track/{message_identifier}) which captures information about the mail you have sent.

So, when a user opens the email, image-tag call the external resource with necessary parameter in the request. And then the external resource process the request and return a transparent image of size 1*1.

Below is the code snippet for adding image to the email body in Java:

var message = new MailMessage("sender@mainhost.com", "receiver@subhost.com");
message.Subject = "Email delivery test using images";
message.Body = "Test with image tag";
String imgTag = "<img src=\"http://externalResource:8080/email-track/{message_id}\" alt="" width=""0"" height=""0""style=""width: 0px; height: 0px; border:0px;";
// append the image tag at the end of the body.
message.Body += imgTag;
message.IsBodyHtml = true;
var client = new SmtpClient("emailhost.com");
client.Send(message);

In the above code, message_id would be a unique identifier of the email. As and when receiver opens the email a request will go to the external-resource with a unique message identifier. And, external-resource will retrieve the message_id from the request and will return a transparent image and can relevant processing using the unique identifier. You can send in more parameters if you need it for your case.

So these are two of the ways using which we can enable email tracking but none of them assures 100% success as both have their own limitations. But I personally like email tracking using image-tag mechanism than read-receipt because it is independent of mail server and can be done without any knowledge of receiver.

Discover and read more posts from Gaurav Yadav
get started