Stape

Avoid Google Tag Manager blocking by Adblockers

Author
Stape
Published
September 16, 2021
Also available in

Ad Blocking is in no way a one-way street, and the impact of tracking script blocking extends far beyond just advertisements.

Many have been made about ad blocking apps and extensions these days, but what do they really do for users? One reason why people might consider installing adblokers on their device or browser is because of annoying ads and pop-ups that appear on the sites. But not only ads can be affected by AdBlockers.

In this post, I will discuss how ad blockers can affect scripts placed using Google Tag Manager. I will also show how to avoid GTM blocking by adblockers using server-side tracking. 

This post is not encouraging anyone to track users without their permission. You should always respect user decisions and ask for their consent before firing any tracking scripts. 

Some people might use GTM for non-tracking purposes (like implementing schema markup or adding a chat on the site). If GTM is blocked, it might negatively impact organic rankings or customer experience. 

How Ad Blockers affect Google Tag ManagerCopy link to this section

Adblocker is a software or browser extension that can alter or remove advertising content from websites. It can block advertising, tracking, and other content using different methods. One of the methods is by targeting the URL where this content originated. 

By default, most ad blockers prevent only ads from being shown. It can be done either by knowing the URL of the advertising network (because of a specific database of URLs that is part of advertising networks) or using the names of tags in the code. 

The default setup of the adblockers won’t hurt Google Analytics or Google Tag Manager. They will block only ads on the page that the user visits. 

But users can adjust settings and ask adblockers to remove any tracking scripts. In this case, Google Tag Manager won’t work. It means that all scripts added inside the Tag Manager won’t work. If you add Google Analytics scripts outside of Google Tag Manager, it will be blocked as well. 

In the past few years, more and more people have been using adblockers to escape advertisements. Since advanced settings of AdBlocker can affect GTM, your tags will be affected too. People might not even know that when they enable the advanced setting of ad blockers, they might block, for example, the ability to contact support via chat on the site.

How to avoid Google Tag Manager blocking by Ad BlockersCopy link to this section

2. Log in to your stape.io account -> Click Settings on the right side of the container -> Click Install web GTM

add custom loader stape

3. Paste your Web Google Tag Manager ID. Once you’ve clicked update, you will see a modified GTM code that you’ll need to update on your website. 

Two changes were made:

  • googletagmanager.com domain was be replaced by your custom subdomain (ss.wp-demo.stape.io in my case)
  • gtm.js was be replaced by ottpwgmj.js

These changes will help to avoid Google Tag Manager blocking by ad blockers.

set up custom loader stape

4. Update the GTM code on your site with the GTM code you copied on the previous step. 

Enable adblocker and use the console to check if GTM is loaded. Google Tag Manager code was not blocked, but you might see that the Google Analytics request was blocked. In the next step, I will show how to prevent Google Analytics from being blocked.

test GTM request

5. To prevent Google Analytics script blocking, you will need to set up server-side Google Analytics. If you just add a transport URL to the GA tag in the Google Tag Manager web container, most Ad Blocker and Brave will still block GA requests. 

This method has a few steps:

  • Setting up Data Tag that will pass user data from web to server GTM 
  • Setting up Data Client that will process Data Tag requests inside the GTM server container.
  • Set up UA tag in the server container that will process info from Data Client requests.

6. Add Data Tag from the GTM Web template gallery.

add data tag to web google tag manager 

7. Create a new tag -> Tag type Data Tag -> Select event name -> Add you GTM server URL ->Add preview header -> If you enable Send all from DataLayer and Send Common Data, it will allow Data Tag to send all information it can find in the web GTM to the server GTM. Add event and user data you want to send to the server container.

set up data tag web google tag manager

8. Open server container -> download Data Client from the Github -> Open template tab and click Add New in the Client Templates section -> click Save.

import data client template

9. Create a new Client -> Client type Data Client

10. Create a new Tag -> Tag type Universal Analytics (or Google Analytics 4) -> Add Universal Analytics ID (or GA4 ID) -> Add client_id

Universal Analytics or Google Analytics 4 tags won’t work without client id.

You have two options here:

  • add client_id manually. In this case, you will need to add client_id in the UA server tag
  • use client_id that Data Tag generates. In this case, you will need to enable “Always generate client_id parameter” in the Data Client in the server container.
set up server-side universal analytics tag

11. Create a trigger for UA tag -> Trigger type Custom -> Client Name equals Data Client

set up server-side universal analytics trigger

12. Open the preview mode of the web and server GTM containers. You should see that Data Tag triggered in the Web container and UA tag triggered in the server container.

test data tag
test server-side universal analytics request

13. If you see that both tags fired, publish web and server containers. Now you can test the setup with adblocker. 

Enable GTM server preview mode again and copy the preview header by clicking three dots at the top right corner -> Click send request manually -> Copy X-Gtm-Server-Preview HTTP header.

send request manually data tag

Open stape.io account -> Click Settings -> Preview Header config -> Paste preview header you copied on the previous step -> Save.

preview header data tag stape

Open your website with enabled adblocker. Open console and check if Data Tag requests worked.

test data tag request

You should also see that UA tag triggered in the Server GTM preview. 

test universal analytics request 

14. To test that Universal Analytics worked, you can use UA Real-Time reports. 

!

After you've finished testing, do not forget to remove the preview header from your stape.io account.

Conclusion:Copy link to this section

Google Tag Manager is not a tracking tool by design and can be used for many other purposes other than tracking user behavior on the site. That is why blocked GTM can negatively impact not Google Analytics, Facebook, or any other tracking tool but can go far beyond it.   

In this blog post, I showed how to use server-side Google Tag Manager to avoid GTM blocking by Ad Blocker. Hope this method won’t be misused. In the end, it is up to you whether or not to set up Google Tag Manager as described in this article.

Tagged with:GTM

Host your GTM server at Stape

By signing up you agree to Stape’s Terms of Use and Privacy Notice