【问题标题】:Users visits not being sent to my Analytics account未将用户访问发送到我的 Analytics 帐户
【发布时间】:2020-08-23 02:15:47
【问题描述】:

我想在我的 react 应用程序上实现 Google Analytics,我已经使用 react-ga 模块进行了设置。

import ReactGA from "react-ga";
...
ReactGA.initialize('analytics-code-here');

const App = () => {

    useEffect(() => {
        ReactGA.set({ page: window.location.pathname + window.location.search});
        ReactGA.pageview(window.location.pathname + window.location.search)
    }, [])

    return (
       ...
    );

我在两天前设置了它,但没有数据发送到我的分析帐户。
如何将数据接收到 Google Analytics 中?

【问题讨论】:

    标签: reactjs google-analytics react-ga


    【解决方案1】:

    对于页面浏览量,您不需要使用set 命令,只需使用这些行来初始化 GA 和跟踪页面浏览量:

    import ReactGA from 'react-ga';
    ReactGA.initialize('UA-000000-01');
    ReactGA.pageview(window.location.pathname + window.location.search);
    

    https://github.com/react-ga/react-ga

    【讨论】:

    • 谢谢。我已将其删除,但它在我的分析帐户中没有显示任何内容
    • UA代码对吗?您是否在控制台/日志中遇到了一些错误?
    • 我在 ReactGA 中将 debug 设置为 true,它只输出相同的函数和一些变量及其值,但没有错误
    • 是的,确实如此。我在制作网页时都尝试过,只是它以 UA- 开头,我也尝试过作为 web + 应用程序,但两者都没有显示任何内容
    • 什么版本的反应?看到这个帖子:stackoverflow.com/questions/49398355/…
    猜你喜欢
    • 1970-01-01
    • 2018-01-15
    • 1970-01-01
    • 2018-07-21
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 2016-03-15
    • 1970-01-01
    相关资源
    最近更新 更多