How to remove "_gl=xxxxxxxxx" suffix added automatically by google analytics GA4 to external links on my webpage

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

How to remove "_gl=xxxxxxxxx" suffix added automatically by google analytics GA4 to external links on my webpage

问题

我想做的是避免GA4自动向我网页中的每个外部链接添加"_gl=xxx"这种后缀。

我在GA4属性管理中几乎尝试了所有方法,比如禁用"click"事件跟踪(实际上我已经禁用了自动事件检测,也禁用了用户提供的数据)。

此外,我修改了js跟踪代码,类似于这样:

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

  gtag('config', 'G-XXXXXXXX', { 'linker': {
    'domains': ['midomain.com'],
    'decorate_links': false
  }
  });
</script>

试图禁用外部链接跟踪的代码。

但似乎什么都不起作用。

注意:在这个网站上,我没有额外的标签管理器配置,并且在我的页面中没有任何代码/服务可能会添加这种"让人讨厌"的链接后缀。实际上,如果我禁用GA4,所有这些"_gl=xxxxxxxx'的url后缀就会消失。

对于如何解决这个问题,有什么想法吗?

非常感谢你们提前的帮助。

英文:

What I would like to do is to avoid that GA4 automatically add those kind of "_gl=xxx" suffixes to every external link that I have in my webpage.

I've tried almost everything in GA4 property admin, like disabling "click" event tracking, (actually I have disabled automatic event detection and I have disabled user-provided-data too.

In addition I have modified js tracking code doing something like this:

&lt;script async src=&quot;https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX&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-XXXXXXXX&#39;, { &#39;linker&#39;: {
    &#39;domains&#39;: [&#39;midomain.com&#39;],
    &#39;decorate_links&#39;: false
  }
  });
&lt;/script&gt;

In a "desperate" attempt to disable external links tracking coding.

But nothing seems to work.

NOTE: I have no tagmanager additional configuration implemented on this site, and there is no code/service in my page that could be doing something like adding that "annoying" suffix on my links. In fact if I disable ga4, all those "_gl=xxxxxxxx' url suffix, disappear.

Any Ideas about how to solve it?.

Thank you in advance for your help guys.

答案1

得分: 1

这个字符串是客户端/会话 ID。Google Analytics(GA)这么做是为了在跨顶级域名跟踪配置的一部分中保持 ID 的一致性。您可能在那里有一些不合理的逻辑,将所有域标记为需要进行跨域跟踪。您可以在这里了解更多信息。以下是如何进行操作:

  1. 在管理界面中,点击属性列中的数据流。
  2. 点击 Web,然后点击一个 Web 数据流。
  3. 在 Web 数据流详细信息中,点击配置标签设置(在底部)。
  4. 在设置部分,点击配置您的域名。

现在,如果您确实需要跨域跟踪,但想要删除 GA 添加的 URL 参数,那么您需要后端支持。您的后端将不得不维护连接并设置 GA Cookie。这更加复杂,但在前端看起来更加优雅。

英文:

That string is a client/session id. GA does so to keep the ids consistent across top-level domains as a part of its cross-domain tracking configuration. You likely have poor logic there that flags all domains for cross-domain tracking. You can learn more about it here. Here is how to get there:

> 1. In Admin, click Data Streams in the Property column.
> 2. Click Web and then click a web data stream.
> 3. In the web stream details, click Configure tag settings (at the bottom).
> 4. In the Settings section, click Configure your domains.

Now, if you do need the cross-domain tracking, but want to remove the url parameter that GA adds, then you will need backend support for it. Your backend will have to maintain the connection and set the GA cookie. It's much more complex, but looks elegant on the front-end.

huangapple
  • 本文由 发表于 2023年3月9日 19:07:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683765.html
匿名

发表评论

匿名网友

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

确定