Avoid Google Tag Manager blocking by Adblockers

Mar 15, 2024
Sep 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 adblockers can affect tracking scripts that are placed in 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 account and choose a container-> Click Power-ups  -> Click Config near the Custom web GTM loader.

custom loader to make gtm and ga4 scripts resistent to ad blockers

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:

  • domain was be replaced by your custom subdomain ( in my case)
  • gtm.js was be replaced by ottpwgmj.js

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

custom loader to make gtm and ga4 scripts resistent to ad blockers

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

Impact of Adblockers on server-side Universal AnalyticsCopy link to this section

universal analytics is dead

5. Server-side Universal Analytics makes data more accurate compared to web UA. But most Ad Blocker or Brave browsers will still block ss UA requests. There is a way to make UA even more resistant to tracking prevention mechanisms.

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.

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 ga4

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 -> Add Universal Analytics ID -> Add client_id

Universal Analytics 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 account and choose a container -> Click Power-ups -> Preview Header config -> Paste preview header you copied on the previous step -> Save.

Preview Header config
Preview Header config

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 account.

Server-side GA4 and AdblockersCopy link to this section

Similar to UA, Google Analytics 4 data can also be affected by tracking prevention software. There is a way to overcome such situations by using stape's custom GA4 loader. If you already set up a custom web GTM loader, then the GA4 loader should also work. All you need to do is open your site, go to the Network tab and check the GA4 request. It should look like the screenshot below. If you did not set up a web GTM loader, just follow these steps to enable custom loader power-up. 

custom Google Analytics 4 loader

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 only 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.

Got confused?

All it takes is a few simple questions. Click Get A Quote, fill up the form, and we will send you a quote.

Get A Quote
Tagged with:gtm server

Host your GTM server at Stape