简体   繁体   English

将 Google 标签 (gtag) 与 Google 标签管理器结合使用

[英]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.

相关问题 使用 Google Tag Manager 动态触发 gTag 事件 - Dynamically Firing A gTag Event with Google Tag Manager gtag / google_tag_manager 混淆 - gtag / google_tag_manager confusion 使用gtag.js安装Google跟踪代码管理器 - Use gtag.js to install Google Tag Manager Google 跟踪代码管理器不接受基本的 GTAG 脚本 - Google Tag Manager doesnt accept a basic GTAG script 如何使用 Google 跟踪代码管理器(而不是 gtag.js)为酒店广告系列设置转化跟踪? - How to set up conversion tracking for hotel campaigns using Google Tag Manager (instead of gtag.js)? Google跟踪代码管理器,并使用触发器或代码排序 - Google Tag Manager and using triggers or tag sequencing 结合Google Analytics(gtag.js)和Google跟踪代码管理器(gtm.js) - Combining Google Analytics (gtag.js) and Google Tag Manager (gtm.js) 如果我已经在使用 Google 标签管理器来提取 Google Analytics,我是否需要全局站点标签 (gtag.js) 才能与 Adwords 配合使用? - Do I need the Global Site Tag (gtag.js) for optimal use with Adwords, if I'm already using Google Tag Manager to pull in Google Analytics? 将“Google 跟踪代码管理器”与“Google 协作平台”一起使用 - Using "Google Tag Manager" with "Google Sites" Google跟踪代码管理器代码容器 - Google Tag Manager tag containers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM