Skip to main content
  1. Blog Post/

Detecting if Google Analytics is being blocked using a Google Tag Manager Custom Template Tag

2 min · 423 words

Today I'm releasing a small Custom Template for Google Tag Manager that will take care of notifying the dataLayer about if Google Analytics is currently being blocked by the browser.

Some days ago, I published the following tweet, to get some user's feedback on Twitter. The approach not really bad, but having to deal with code is not the best solution for most people.

I decided today to build a quick Custom Template to take care of checking if Google Analytics is being blocked. We'll simply using the sendPixel library from Custom Templates. If you didn't know if sendPixel library allows you to fire an onSuccess or onFailure callback functions.

Then based on these callbacks the template will be push the data accordinlty to the dataLayer. And from there you may do whatever your want, like notifying an external application with an event, or showing the user any alerts ( this was just a dummy idea, please don't annoy the users on this ).

sendPixel(url, onSuccess, onFailure)

The Custom Template has some configurations available to fine-tune que current behaviour of the tracking.

    If you're insterested on trying it, you can DOWNLOAD it from my github repo:
    https://github.com/thyngster/gtmtemplates/tree/master/Google%20Analytics%20Block%20Checker