Introduction
Most of the email users get a number of opt-in emails each day. Many of you might have noticed that a marketing campaign starts and sends out a number of emails. At the beginning, you might have interested reading such advertising. And eventually you stopped reading them. But the marketing company would not stop sending you emails and you also didn't opt-out yourself from the mailing list! Although after a certain period of time, you might have noticed that the company stopped sending you further emails.
Question is that, did they stop their campaign? Answer is 'possibly no'. So why they stopped sending you email. Did they know that you are not reading their emails? Answer is 'probably yes!' 'Yes?' - but how they could know that you are no longer interested in reading their email offers?
Background
It's all about a technique called 'email tracking'. By email tracking, a marketing company can track whether you read a particular post. That is, after sending emails to you, they can track out whether you've read those emails at all. Even surprisingly, they can also track the location and date/time when (and from where) you've read those emails!
Is it really possible at all? Yes technically it's very easy to track emails whether they are read or not!
Before we go into too depth, we must understand that only email containing HTML as part of its MIME type can be used to be tracked. As you know, in an HTML email we can easily put a graphics in it. Graphics can be very nice image, or it can simply be an invisible image (a transparent image with 1x1 size for example).
When we put an image into an HTML source we write similar to the following:
<img src="some-source-onto-your-server.gif"/>
But when it's required to track an e-mail's status, the src property of the <img> element looks a bit trickier. Consider the following:
<img src="ImageServer.aspx?imageID=track.jpg& custID=134ghxx34343ai& campID=32434"/>
Using the code
As you can guess easily that the image source url itself (the src property of the <img> tag) does not point to an image type file, instead it's a query string to be executed within an .aspx file (may be also .jsp, .php etc.). That's all behind the scene. The code inside the ImageServer.aspx.cs
is as simple as following:
private void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "image/jpeg";
if (!IsPostBack) Track();
Response.WriteFile(GetImageFileByID());
}
When the browser sends a GET method using the above query string, the .aspx file parses the query, determines who the user opens the email up to read, then the program stores a flag in the database table to indicate that a particular email for a particular campaign has been opened by the customer. Additionally the program can also store other information; such as date/time information, remote IP to determine location information etc.
In my code, I have used an index.aspx
file as if it were an email previously sent to a customer to mimic the fact when such email tracking occures in real life.
Test vs Real Life Project
Please bear in mind that in a real life and fit-to-production-environment email campaign solution, this implementation can't give the ultimate performance. Usually for such big real life project, one need to implement fully fledged tracking server, which acts like a web server (almost like the IIS itself).
Final Thoughts
Upon only one reason the above program may fail to track to determine whether a particular email has been opened or not - if the email client (such as Yahoo or MSN) disables the graphics to be downloaded for email containing HTML content. In Yahoo Mail, user can set their preference not to download graphics for their emails. In this case <img> tags are tweaked by the Yahoo Server, and hence no graphics would be downloaded from other servers. So as no image to download, no tracking to occur at the marketing agent's end!!!
That's all about email tracking!!