Google Analytics代码与容器代码相对应(Google Analytics tag vs Container tag)

编程入门 行业动态 更新时间:2024-10-25 22:36:15
Google Analytics代码与容器代码相对应(Google Analytics tag vs Container tag)

我是Google跟踪代码管理器的新手。 我正在线阅读支持文档( https://support.google.com/tagmanager/answer/6102821?hl=en )并查看以下内容:

Google Tag Manager works via its own container tag that you place on all your website pages. The container tag replaces all other tags on your site, including tags from AdWords, Google Analytics, Floodlight, and 3rd party tags.

这似乎告诉我GA标签与容器标签不同? 我有一个现有的网站,我知道它正在做一些GA的事情,但我如何判断标签是GA标签,还是做GA的容器标签? GTM-XXXXXX部分是否表明它是容器标签?

I am new to Google Tag Manager. I am reading a support document online (https://support.google.com/tagmanager/answer/6102821?hl=en) and see the following:

Google Tag Manager works via its own container tag that you place on all your website pages. The container tag replaces all other tags on your site, including tags from AdWords, Google Analytics, Floodlight, and 3rd party tags.

This seems to be telling me GA tag is different from a container tag? I have an existing website that I know it is doing some GA things, but how can I tell if the tag is a GA tag, or a container tag that does GA? Does the GTM-XXXXXX portion indicates that it is a container tag?

最满意答案

GA代码段或用于启用GA的代码块与GTM代码段不同。

正如您所指出的那样,“gtm.js”的存在(如下面的GTM容器中所示)或“GTM-XXXXX”表示您最有可能使用GTM。

<!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-ABC123" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-ABC123');</script> <!-- End Google Tag Manager -->

存在“analytics.js”,如下面的代码段所示

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

表示您直接使用GA。

您也可以在页面上同时拥有两个代码片段,这通常不是最佳实践,因为您可以使用GA代码执行的所有操作都可以通过GTM完成。 另请注意,仅仅因为您在页面上拥有GTM容器代码并不意味着您可以获得即时跟踪。 您需要在GTM中创建标记以捕获网页浏览量和事件。

The GA snippet, or the block of code used to enable GA, is different from the GTM snippet.

The presence of "gtm.js", as shown in the GTM container below, or "GTM-XXXXX", as you've pointed out, indicates that you are most likely using GTM.

<!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-ABC123" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-ABC123');</script> <!-- End Google Tag Manager -->

The presence of "analytics.js", as shown in the snippet below

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

indicates that you are using GA directly.

You could also have both snippets of code on a page, which is not usually the best practise as everything you could do with the GA code, can be accomplished through GTM. Also note that just because you have the GTM container code on a page doesn't mean that you get instant tracking. You need to create tags in GTM in order to capture pageviews and events.

更多推荐

本文发布于:2023-08-04 07:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   相对应   容器   Analytics   Google

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!