Google Tag Manager & Google Ads Conversions Blocked in China?

In this post I will demonstrate my research on how Google Tag Manager, and Google Ads Conversions which relies on it works in China. Is it blocked or not?

GTM Blocked in China

The answer is not that simple;

While the Google Tag Manager script itself is not blocked, as it’s common sense to allow it to run on websites for smoother browsing for the Chinese. The domain “googletagmanager.com” is blocked, disallowing actual use of the service.

If the Google services you are running on your site is blocked or not, also depends on what you are doing with GTM, what scripts it loads, etc.

I was recently setting up Google Ads Conversions (formerly known as Google Adwords) on a website which had plenty of visitors from China.

Turns out, that this was loading up several bits of code, two of which are blocked in China. And therefore potentially slowing down Chinese users.

Here’s how you can find out if you are blocked;

Step 1. Add the required code snippets on a test page somewhere.

Step 2. Load that page with the trusty Pingdom Website Test.

Step 3. Take down all URLs Google is connecting to on page load.

Step 4. Open up the trusty GreatFire Analyzer tool, and test the current censorship/blocked status of each URL, as well as analyze historical data.

Here’s what you can do to avoid getting blocked;

If none of the URLs are blocked at the time, reality is that you never know if situation changes, so you should at least monitor the URLs from time to time.

Even the Google Tag Manager script gtm.js has seen a few temporary blocks in the past. And there are reports that this could make your site slower even if not blocked.

What I’ve done, is simply exclude the code from running for website visitors located in China with content geolocation. It’s the only permanent solution obviously.

Read my guide — location based content geolocation with JavaScript.

While the script is simple and can be used directly with the code snippet demonstrated in the above post, you might consider running the Geolocation API on your own server. And preferably somewhere with good connectivity to mainland China. The ready hosted API is located in London, UK.

My tests for blocks in China;

So when I was setting up Google Ads (or Adwords) Conversions with Google Tag Manager (GTM), these are the URLs I came across in my tests;

https://www.googletagmanager.com/gtag/js (unblocked)

https://www.googleadservices.com/pagead/conversion_async.js (unblocked)

https://googleads.g.doubleclick.net/pagead/viewthroughconversion/ (unblocked)

https://www.google.com/ads/user-lists/ (blocked)

So therefore, I applied a similar code in the header.

<script>
function chinaSwitch(data) {
if (data.country.code === 'CN') {
// No Google Tag Manager for visitors from China
document.write('');
} else {
document.write('\x3Cscript async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXX">\x3C/script>\x3Cscript>window.dataLayer=window.dataLayer || []; function gtag(){dataLayer.push(arguments);}gtag(\'js\', new Date()); gtag(\'config\', \'AW-XXXXXXXXXX\');\x3C/script>\x3Cscript>gtag(\'event\', \'conversion\',{\'send_to\': \'AW-XXXXXXXX/XXX\'});\x3C/script>');
}
}
</script>

<script src="https://geoip.nekudo.com/api/?callback=chinaSwitch""></script>

Although the location data is based on “Maxmind GeoLite2 Database” which is not perfect, it’s pretty good for a completely free solution, updated monthly.

Questions about blockages and hosting Google content in China?
Let us know your experience with Google Tag Manager & Google Ads, etc.

Thanks for reading, Tim.

And please share if you found this useful.

Leave a Comment