How many people block your analytics tracking code?

Analyzing our visitor’s behavior using (among others) Google Analytics (GA) is very important to us. We also use data from GA to provide to our customers. Hence it is very important that the data recorded in GA is accurate and complete. While analyzing the GA data we were missing data. We noticed some pageviews and events were not recorded. The question was why?

First, we thought it may be GA dismissing the pageviews/events for some reason. Maybe a filtering issue. But this hypothesis was quickly ruled out. Then we thought maybe the event is never sent to GA by the end-user. Ad blockers often offer the ability to not only block advertisements but also block tracking scripts. The only way to figure if our assumption was true was to run GA script parallel to the existing GA script that cannot be blocked by the end-user.

GA offers the ability to send each event to your own tracking template. We decided to implement this feature. More information on how to implement this feature can be found here:

Adding to a task
To insert new functionality you can chain your custom task function to execute before or after an existing task. In the example below, the sendHitTask is replaced with a custom task function that first calls the original sendHitTask function to send the normal request beacon to, then executes custom code to send a copy of the measurement protocol request to a local server.

ga('create', 'UA-XXXXX-Y', 'auto');

ga(function(tracker) {

  // Grab a reference to the default sendHitTask function.
  var originalSendHitTask = tracker.get('sendHitTask');

  // Modifies sendHitTask to send a copy of the request to a local server after
  // sending the normal request to
  tracker.set('sendHitTask', function(model) {
    var xhr = new XMLHttpRequest();'POST', '/localhits', true);

ga('send', 'pageview');

Now we were tracking our users using the standard GA implements and we tracked the same users using a custom implementation where the data is being sent to our own servers instead of the GA servers.

The results

Drum rolls please. We found out that about 5% of all pageviews/events were blocked by Ad/tracking blockers. This number has been pretty stable for the last 4 years. For us, this is a very important difference. On other projects we decided to always use a custom implementation of GA like shown in the example above, to prevent having to deal with incomplete data.

Leave a Reply

Your email address will not be published. Required fields are marked *