gtag.js为什么在安装代码中两次指定相同的ID?

huangapple go评论65阅读模式
英文:

Why does gtag.js specify the same ID twice in the installation code?

问题

为什么 G-ZQA9CN2Q3Z 被提及两次?

如果我想同时安装两个 GA4,是否需要加载两次 <script /> 标签?

英文:

The GA4 gtag.js installation code is as follows:

&lt;!-- Google tag (gtag.js) --&gt;
&lt;script
  async
  src=&quot;https://www.googletagmanager.com/gtag/js?id=G-ZQA9CN2Q3Z&quot;
&gt;&lt;/script&gt;
&lt;script&gt;
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }
  gtag(&#39;js&#39;, new Date());
  gtag(&#39;config&#39;, &#39;G-ZQA9CN2Q3Z&#39;);
&lt;/script&gt;

Why was G-ZQA9CN2Q3Z mentioned twice?

Is it necessary to load the &lt;script /&gt; tag twice if I want to install two ga4 at the same time?

答案1

得分: 1

我相信URL中的那个部分通过最初加载指定的ID代码来加快速度。因此,请在URL中指定您最重要的ID,然后配置所有的ID。

如果您检查网络,您会看到每个ID都有一个请求。

英文:

I believe the one in the URL helps speed things up a bit by loading the specified IDs code initially. So specify your most important ID in the URL and then config all your IDs.

If you check the network, you will see there is a request per ID.

huangapple
  • 本文由 发表于 2023年7月3日 16:52:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76603241.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定