[英]Using Google Tag(gtag) with Google Tag Manager
I currently have an implementation of GA4 using gtag in my website and I would like to add GTM too.我目前在我的网站上使用 gtag 实现了 GA4,我也想添加 GTM。 I was wondering if I can use the same endpoint from GA4 (
https://www.googletagmanager.com/gtag/js?id=
) and insert the GTM tag where id is and GA4 and GTM again with config
.我想知道我是否可以使用 GA4 (
https://www.googletagmanager.com/gtag/js?id=
) 中的相同端点,并在 id 所在的位置插入 GTM 标记,然后使用config
再次插入 GA4 和 GTM。
I found this for the documentation <script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
but nothing that specifically talks about using Google Tag with Google Tag Manager.我在文档
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
中找到了这个,但没有专门讨论如何将 Google Tag 与 Google Tag Manager 结合使用。 Almost all of it is about using the GTM interface.几乎所有内容都是关于使用 GTM 界面的。
I found that GTM supports googletag but the endpoint uses https://www.googletagmanager.com/gtm.js?
我发现 GTM 支持 googletag 但端点使用
https://www.googletagmanager.com/gtm.js?
It's not recommended since GTM can load gtag and a bunch of other libraries as they're needed and manage them in the most optimal way.不推荐这样做,因为 GTM 可以根据需要加载 gtag 和一堆其他库,并以最佳方式管理它们。 That's why you see a lot more information on GTM than gtag.
这就是为什么您在 GTM 上看到的信息比 gtag 多得多。
Implementing tracking with gtag.js is, in most cases, a mistake unless you don't care much about it and just want to be quick about it.在大多数情况下,使用 gtag.js 实现跟踪是一个错误,除非您不太关心它并且只想快速处理它。
Having said that, yes, you can load both separately.话虽如此,是的,您可以分别加载两者。 GTM will attempt to use the existing gtag library if it needs it.
如果需要,GTM 将尝试使用现有的 gtag 库。 Set up like this, however, requires you to understand how both libraries deploy listeners to the dataLayer array and how they store/use the local state of things.
然而,这样设置需要您了解这两个库如何将侦听器部署到 dataLayer 数组以及它们如何存储/使用本地 state 的东西。 They will also use the same cookies.
他们还将使用相同的 cookies。
Even though the libraries don't conflict in terms of syntax, it's uncommon to have logical tracking issues due to implementations like this.尽管这些库在语法方面没有冲突,但由于这样的实现而出现逻辑跟踪问题的情况并不常见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.