Reputation: 364
It is my understanding the GTM replaces gtag.js. They are two separate technologies, one being the predecessor to the other. Well, I've been trying to guide my company through cleaning up their installments of GTM, gtag.js, and analytics.js. We've found duplicate and co-installations for all of these all over our sites.
My dev team has been unable to remove our gtag.js installation from axelgo.app though. After a lot of digging I found this on Github, and I located this in my browser:
All of this makes me think that GTM is injecting the gtag.js snippet automatically. But this behavior baffles me for a number of reasons.
Given those two reasons, I don't want to believe it is GTM injecting the snippet. It feels quite dirty of Google to do that, should it be true. So my question is, am I right? Or am I wrong and there should be a way to remove the gtag.js instance?
Now, I currently have a bunch of events from staging servers inside my GA4. I have GTM set up not to fire anything if the hostname is not the production server's though. So I can only assume the data leak is coming from this rouge gtag.js snippet. I really appreciate any help on this. How can I get rid of this? The injected snippet is:
<script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=G-4YJDRFJTFE&l=dataLayer&cx=c"></script>
Upvotes: 1
Views: 554
Reputation: 364
Answering my own question here. My investigation turned up that GTM does in fact inject that snippet of code. Also, yes it does resemble the gtag.js snippet (top line). However, it is not gtag.js. It is a part of GTM, though I'm not exactly sure what it is doing.
The similar syntax to gtag.js, accompanies by the lack of documentation on this behavior and the fact that I was experiencing a data leak, resulted in myself misconstruing that snippet as the cause of my problem.
The real issue was identified inside GTM. The container utilized by our staging servers did have a configuration tag referencing the production GA4 account. I removed it and all is fine now.
Upvotes: 1