Google Analytics(分析)GA4,用户可能被两倍计数?
我猜测Google Analytics(分析)中的转介
指标在其中有一个ref
(来自其他站点,例如 https://website.com?ref=facebook ) >参数从URL删除,是否会增加Direct
度量?
仅仅想确保用户从昨天开始就不会被仔细计算,推荐
和直接
公制是相同的,这很奇怪。如果是这样,是否有一种方法可以确保它们不被两倍计数?
使用GA4
GTAG.JS _APP.TSX
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
export const pageview = (url) => {
window.gtag("config", GA_TRACKING_ID, {
page_path: url,
});
};
export const event = ({ action, category, label, value }) => {
window.gtag("event", action, {
event_category: category,
event_label: label,
value,
});
};
在NextJS应用中
const router = useRouter();
useEffect(() => {
const handleRouteChange = () => {
gtag.pageview(window.location.href);
};
router.events.on("routeChangeComplete", handleRouteChange);
router.events.on("hashChangeComplete", handleRouteChange);
return () => {
router.events.off("routeChangeComplete", handleRouteChange);
router.events.off("hashChangeComplete", handleRouteChange);
};
}, [router.events]);
I'm guessing the Referral
metric in Google Analytics increments when the url has a ref
in it (coming from a different site such as https://website.com?ref=facebook), but if the user clicks on a separate page and the ref
param is dropped from the url, does that increment the Direct
metric?
Just want to make sure users aren't being double counted since just yesterday the Referral
and Direct
metric were the same which was odd. If that is the case, is there a way to make sure they are not double counted?
Using ga4
gtag.js
export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
export const pageview = (url) => {
window.gtag("config", GA_TRACKING_ID, {
page_path: url,
});
};
export const event = ({ action, category, label, value }) => {
window.gtag("event", action, {
event_category: category,
event_label: label,
value,
});
};
_app.tsx in NextJS app
const router = useRouter();
useEffect(() => {
const handleRouteChange = () => {
gtag.pageview(window.location.href);
};
router.events.on("routeChangeComplete", handleRouteChange);
router.events.on("hashChangeComplete", handleRouteChange);
return () => {
router.events.off("routeChangeComplete", handleRouteChange);
router.events.off("hashChangeComplete", handleRouteChange);
};
}, [router.events]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论