简体   繁体   English

Google Analytics 4 不会在虚拟页面视图上发送 `page_view`(`hashchange` 源的`historyChange` 事件)

[英]Google Analytics 4 doesn't send `page_view` on virtual page views (`historyChange` event for `hashchange` source)

I added Google Analytics 4 to a React project via script tags in index.html .我通过index.html中的脚本标签将 Google Analytics 4 添加到 React 项目中。 Enhanced measurements are enabled and virtual page views should be tracked automatically.启用增强测量,并且应自动跟踪虚拟页面浏览量

在此处输入图像描述

page_view events are registered correctly on the dashboard when opening or reloading the page. page_view事件在打开或重新加载页面时在仪表板上正确注册。

However, there are no page_view events fired on virtual page views.但是,没有在虚拟页面视图上触发page_view事件。 Ie using HashRouter of React Router, that modifies location.hash .即使用 React Router 的HashRouter ,它修改location.hash

In debug mode I do see the processing of the historyChange event, but no event is sent as a result:调试模式下,我确实看到了historyChange事件的处理,但没有发送任何事件:

Processing commands (1)
js?id=G-*********:165 Processing data layer push: {event: "gtm.historyChange-v2", gtm.historyChangeSource: "hashchange", gtm.oldUrlFragment: "/legal", gtm.newUrlFragment: "/", gtm.oldHistoryState: null, gtm.newHistoryState: null, gtm.oldUrl: "http://localhost:3000/", gtm.newUrl: "http://localhost:3000/", gtm.triggers: "8"}

I know I can manually send page_view events, but I'd love to understand how to make this work out of the box.我知道我可以手动发送page_view事件,但我很想了解如何使这项工作开箱即用。

Project with this setup at cra-typescript-starter@a91a6be97f3693f42289d41209e5d0273de02ee5cra-typescript-starter@a91a6be97f3693f42289d41209e5d0273de02ee5使用此设置进行项目

I believe this happens with HashRouter because gtag ignores the hash part of the URL.我相信HashRouter会发生这种情况,因为gtag忽略了 URL 的 hash 部分。 Can't find this mentioned in the docs but it seems so from my testing and there are other mentions of this behavior: 1 , 2找不到文档 提到的这一点,但从我的测试来看似乎如此,并且还有其他提到这种行为: 1、2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法禁用 Google Analytics page_view 事件 - Can't disable Google Analytics page_view events Google Analytic GA4 不会禁用 React 应用程序中的默认 page_view 事件 - Google Analytic GA4 does not disable default page_view event in React Application Gtag 和 Google Analytics 事件和网页浏览量衡量 - Gtag and Google Analytics events and page view measurement 如何使用到达路由器和谷歌分析跟踪页面浏览量? - How to track page views in react using reach router and google analytics? 谷歌分析中使用的“按页面标题和屏幕类别查看”的图表是什么? - What chart used in google analytics for “Views by Page title and screen class”? 谷歌分析仅在页面刷新时更新页面视图 - Google analytics only update page view when page is refreshed GA4 Google Analytics 事件未显示为转化 - GA4 Google Analytics event doesn't appear as conversion 为什么谷歌分析不跟踪特定的用户浏览量和其他活动? - Why doesn't google analytics track specific user views and other activities? 如何获得页面浏览量等报告,用户在谷歌分析上的特定页面上花费多长时间? 不是一般报告 - How to get a report like page views, how long a user spends time for a specifice page on google analytics? Not a general report 查看页面源代码在 nextjs 中不显示页面 - view page source does not show page in nextjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM