对自定义标签使用全局站点标签(ga gtag)代码

时间:2019-11-22 15:05:53

标签: google-analytics gtag.js

可以将GA中的一个gtag代码用于自己的标签,还是标签管理器在每个页面上都需要另一个标签?

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=xxxx"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', xxx');
</script>

1 个答案:

答案 0 :(得分:0)

根据 Google Analytics 文档:

<块引用>

要安装全局网站代码,请复制以下代码并将其粘贴到您网站的每个页面上的代码之后。将 GA_MEASUREMENT_ID 替换为您要向其发送数据的 Google Analytics(分析)媒体资源的 ID。 每页只需要一个全局代码段。

https://developers.google.com/analytics/devguides/collection/gtagjs#install_the_global_site_tag