A 1-post collection

Measure how many of your visitors that are using Adblock - and Ghostery

I had the great pleasure of meeting Daniel Carlbom, a senior data analyst at NetBooster, while at the  Google Analytics Conference Nordic 2015 in Stockholm. He gave a talk on how to measure how many of the visitors to your site are using adblock. Using this script, you get a fairly good benchmark on how many of your visitors will never see the ads you are buying. This in turn should be used to analyze the segments of users that are difficult to reach via conventional online ads and therefore should be targeted by different means.

One hypothesis can be that more people have adblock on their personal computer than at home. If this is the case, those users should be targeted during working hours. What browser are the adblockers using, and on what device? Whatever you decide to analyze, it is important to know the share of your own visitors that are using adblock.

Although measuring this is important, it can also be inherently difficult. Particularly as an increasing number of people are installing the Ghostery add-on, making it possible to «choose whether you want to block tracker-by-tracker, site-by-site, or a combination of the two». This often means that both Google Tag Manager and Google Analytics are being blocked and thus prevented from tracking the visit.

In the ideal world, we would like to know how many are using an adblocker and how many of our visitors have Ghostery installed, and it should look something like this in Google Analytics

Users with adblocker or GhosteryUsers with adblocker or Ghostery

Taking this a bit further

Using the method devised by Daniel to determine if an adblocker is present, we can build on this to also include a method to guess if the Ghostery add-on is installed.

Nick Nikiforakis has done most of the work for us when it comes to detecting Ghostery, update this to look for the title-attribute instead of the element id.

Because Ghostery often prevents Google Tag Manager and Google Analytics from loading, recording if the user has blockers installed has to be done in the background.

Enter the proxy page

The first time a user visits the site, javascript checks if adblock and/or Ghostery is installed. A small script then changes all the links on the page to a proxy-page that then registers the outcome of the adblock check with Google Analytics, before sending the user on its way to the original page. It is important to note that the call to Google Analytics should be handled in the background, so that the user can be sent on their way as soon as possible and not have to wait for the Google Analytics call to complete. The whole process can be illustrated like this

An illustration of how the detection of adblockers and Ghostery works with the proxy page on first visitAn illustration of how the detection of adblockers and Ghostery works with the proxy page on first visit

The proxy page sets a cookie that’s valid for 7 days before checking again for adblockers, it also sets a valid Google Analytics cookie that’s sent with the event. This cookie is then used later when the user visits the site again, either with directly with Google Analytics or via the proxy page.

An illustration of how the detection of adblockers and Ghostery works with the proxy page on second visitAn illustration of how the detection of adblockers and Ghostery works with the proxy page on second visit and when the cookie exists

There is a tiny cost with this solution as it sends the user to the proxy page before being redirected to the final destination, however, this shouldn’t cost more than 2 – 300 ms in addition to the extra redirect.

Using the cookie that’s set by the proxy page, the links are only changed and the user redirected to the proxy page every seven days. This means that the adblock check and Ghostery-check is run every seven days, which in turn enables us to see the trend over time if there is a change in adblock usage per user.

Using this data, it’s possible to deduce how many of your users will never see the ads you spend your money on and even try to segment them out in your audiences.