Thomas Andrew Hansen
Tech
Tutorials
How to make Email Open Tracking slightly more accurate

Having issues with your email open tracking not being accurate? Me too... Sendgrid amoung other others help send out batch emails and have the functionality of tracking Opens of emails. However it seems to be very innaccurate due the way Opening tracking works.

How Email Open Tracking Works

Email Open tracking works by adding a invisible 1px X 1px image to the end of the email thats being sent. Amoungst the user receiving the email and opening up. The email images would load aswell and the email would be tracked as open. However there is a problem..

The problem with Email Open Tracking

The Problem with this method of email open tracking is that most email clients have functionailty (usually by default) to leave email images unloaded. Which means most user who receive these emails not being tracked as open. Frustrating right?

Whats even ore frustrating is that if you have click tracking turned on, sometimes a user will click the link, marking it as clicked however still remaining unopened? How does that work? Sounds silly right.

The only real way around it is by adding any email that was clicked and checking to see if it has an "open" status aswell. Then adding a "open" status if doesnt already have one.

Sounds pretty simple right? Well it is...

What the fix?

This fix will help add open tracking to any user that has received the email and have clicked on a link that has been added. So at least the open count should be the same or more the click count, making the stats look a little bit more accurate.

Here is the typescript version in Angular:


this.statData.recipients
        .forEach(recipient => {
            const clicked = recipient.sendStatuses.filter(sendStatus => sendStatus.status === "click").length;
            const opened = recipient.sendStatuses.filter(sendStatus => sendStatus.status === "open").length;

            this.opens = this.opens + opened;
            this.clicks = this.clicks + clicked;

            let hasBeenOpened = false;

            if (opened > 0) {
                this.uniqueOpens++;
                hasBeenOpened = true;
            }
            if (clicked > 0) {
                this.uniqueClicks++;
                if(!hasBeenOpened){
                    this.uniqueOpens++;
                    this.opens++;
                }
            }
        });

    this.clicksPerUniqueOpens = (this.clicks / this.uniqueOpens * 100).toFixed(2) + ' %';