[英]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@a91a6be97f3693f42289d41209e5d0273de02ee5在cra-typescript-starter@a91a6be97f3693f42289d41209e5d0273de02ee5使用此设置进行项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.