Click here to Skip to main content
15,881,248 members
Articles / Web Development / ASP.NET
Article

Tracking Emails for Open/Read

Rate me:
Please Sign up or sign in to vote.
4.14/5 (24 votes)
9 Aug 20063 min read 149.6K   4.1K   73   23
Tracking Emails for Open/Read

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:

C#
private void Page_Load(object sender, System.EventArgs e)
{
    // content type should be resolved programmatically
    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!!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect TechAnts Technologies Limited
Bangladesh Bangladesh

Mohammad Ali Azam has been working as an Architect in TechAnts Technologies Limited, located in Dhaka, Bangladesh since 2008.


Azam had long been working as a Senior Java Enterprise Architect in several companies and now has been working on software development using ASP.NET platform. He is as competent in both Visual C# and Visual Basic .NET as he is in J2EE.


For last couple of years, he has actively been working on Email Campaign Software, ECMS, Search Engine Integration, Hospital Management System, Knowledge Management System, Human Resource Management System and open source PHP web application such as Joomla, WordPress and Magento. Along with his regular tasks in the industry, he has also been researching on inventing technologies to promote Rapid Application Development (RAD).


While he works on designing various component models utilizing the best industry practices and the latest specification of UML, at leisure, he plays with his little baby girl and watches Sci-Fi movies on satellite TVs (or on DVDs) with his
wife!


Comments and Discussions

 
QuestionEmail Tracking Pin
Milton B.29-Jan-16 6:09
professionalMilton B.29-Jan-16 6:09 
GeneralTrackimg for email is not working in Gmail account Pin
Member 1053231630-Mar-14 19:42
Member 1053231630-Mar-14 19:42 
GeneralRe: Trackimg for email is not working in Gmail account Pin
Member 142189927-Apr-19 19:58
Member 142189927-Apr-19 19:58 
QuestionExpose User ID? Pin
Tam Vu11-Jan-11 4:18
Tam Vu11-Jan-11 4:18 
QuestionWhat if User not Click on display images... Pin
shaikhsamir4-Aug-10 0:13
shaikhsamir4-Aug-10 0:13 
AnswerRe: What if User not Click on display images... Pin
zorou11-Dec-10 16:07
zorou11-Dec-10 16:07 
GeneralNot Working..please help. Pin
S.R.Sahoo3-Jun-10 21:35
S.R.Sahoo3-Jun-10 21:35 
Questionlinks to email tracking server programs Pin
Jayapal Chandran13-Nov-09 19:23
Jayapal Chandran13-Nov-09 19:23 
GeneralEmail Tracking on Forward and Spam Emails Pin
Member 28126005-Aug-08 2:59
Member 28126005-Aug-08 2:59 
QuestionTracking Email for open/read Pin
sudhir_kr22-Jul-08 20:56
sudhir_kr22-Jul-08 20:56 
AnswerRe: Tracking Email for open/read Pin
Mohammad Ali Azam5-Aug-08 20:28
Mohammad Ali Azam5-Aug-08 20:28 
GeneralRe: Tracking Email for open/read Pin
sudhir_kr24-Aug-08 21:13
sudhir_kr24-Aug-08 21:13 
Questioncan u help me to use this for validating email address?? Pin
ibtesam_bloch19-Feb-07 22:08
ibtesam_bloch19-Feb-07 22:08 
AnswerRe: can u help me to use this for validating email address?? Pin
Mohammad Ali Azam27-Feb-07 3:23
Mohammad Ali Azam27-Feb-07 3:23 
GeneralBetter if you use in this way [modified] Pin
Sameers Javed19-Aug-06 2:51
Sameers Javed19-Aug-06 2:51 
GeneralRe: Better if you use in this way Pin
Mohammad Ali Azam27-Feb-07 3:25
Mohammad Ali Azam27-Feb-07 3:25 
GeneralRe: Better if you use in this way Pin
Rabindranathsenpati16-Mar-07 4:12
Rabindranathsenpati16-Mar-07 4:12 
GeneralRe: Better if you use in this way Pin
Sameers Javed16-Mar-07 10:37
Sameers Javed16-Mar-07 10:37 
GeneralSmart technique, but ... Pin
mgungora16-Aug-06 1:40
mgungora16-Aug-06 1:40 
GeneralRe: Smart technique, but ... Pin
Mohammad Ali Azam16-Aug-06 21:16
Mohammad Ali Azam16-Aug-06 21:16 
GeneralTracking email: nice but... Pin
Ngo Tran Anh15-Aug-06 23:53
Ngo Tran Anh15-Aug-06 23:53 
If you do like this, your recipient's mail server/client will filter your mail out because they do think it's spam.
GeneralRe: Tracking email: nice but... Pin
Mohammad Ali Azam16-Aug-06 21:13
Mohammad Ali Azam16-Aug-06 21:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.