Google跟踪代码管理器导致SPA中重新加载整个页面-React [英] Google Tag Manager causes full page reload in SPA - React

查看:86
本文介绍了Google跟踪代码管理器导致SPA中重新加载整个页面-React的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在React的<a /><Link />元素上的GTM中添加触发器时,它会导致单击时重新加载整个页面,而不是仅重新呈现应用程序的一部分.

When I add trigger in GTM on a React <a /> or <Link /> element it causes full page reload on click instead of re-rendering just part of application.

当我删除Google跟踪时,一切都会顺利进行.有没有一种方法,如何配置GTM以不影响应用程序的行为?

When I remove google tracking, everything works smoothly. Is there a way, how to configure GTM to not affect behaviour of application?

推荐答案

如果Google跟踪代码管理器链接发生了奇怪的情况,请点击跟踪,您要做的第一件事就是转到点击触发设置,然后查看等待代码" "和检查验证"复选框处于启用状态(默认情况下为选中状态),然后取消选中它们.

If strange things happens with Google Tag Manager link click tracking the first thing you should do is to go to your click trigger setup and see if the "wait for tags" and "check validation" checkboxes are enabled (as they are by default) and uncheck them.

它们在SPA中不是必需的,并且(已证明)潜在有害; 等待标签"会增加延迟,以使其他标签有时间触发链接,从而引导用户离开页面(无论如何在SPA中都不会发生),检查验证"会测试链接目标是否为有效的URI(在SPA中,它可能不是GTM的标准,例如,以哈希开头的链接无效等).

They are not necessary in an SPA and (as evidenced) potentially harmful; "wait for tags" adds a delay so that other tags have time to fire before a the link directs a user away from the page (which does not happen within SPAs in any case), "check validation" tests if the link target is a valid URI (which within an SPA it probably isn't by GTMs standards - for example links starting with a hash are not valid etc.).

这篇关于Google跟踪代码管理器导致SPA中重新加载整个页面-React的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆