简体   繁体   English

React Google Analytics - 事件发送但不显示

[英]React Google Analytics - Events sending but not showing up

I'm using react-ga for Google Analytics:我正在为 Google Analytics 使用react-ga

import ReactGA from "react-ga";

ReactGA.initialize("UA-XXXXXXXXX-X", { debug: true });
ReactGA.pageview("/example");

ReactGA.event({
    category: "Test",
    action: "Click",
    label: "Example"
});

This results in the following output:这导致以下输出:

输出

Which makes me think that everything worked, but Google Analytics doesn't show the event on my dashboard.这让我认为一切正常,但 Google Analytics 没有在我的仪表板上显示该事件。 I also tried the following:我还尝试了以下方法:

ReactGA.ga("send", "event", "Test", "Click", "Example");

Which gave the same output, but with nothing showing up on my GA dashboard.这给出了相同的输出,但我的 GA 仪表板上没有显示任何内容。 I've waited over half an hour and my GA dashboard still doesn't show the data.我已经等了半个多小时,我的 GA 仪表板仍然没有显示数据。 Is there something I'm doing wrong?有什么我做错了吗?

Note: The pageview does go through and shows up on my GA dashboard just fine.注意:页面pageview确实通过并显示在我的 GA 仪表板上就好了。

instead of ReactGA.pageview("/example");而不是ReactGA.pageview("/example");

Try Using ReactGA.pageview(window.location.pathname);尝试使用ReactGA.pageview(window.location.pathname);

I am assertive it will work.我坚信它会奏效。

and have look at the documentation of ReactGa并查看 ReactGa 的文档

https://www.npmjs.com/package/react-ga https://www.npmjs.com/package/react-ga

Scroll Down to ReactGA.event(args)向下滚动到ReactGA.event(args)

There must be an issue with your args你的参数肯定有问题

在此处输入图片说明

Looks like I was just impatient.看来我只是不耐烦了。 It took a while but the events did eventually show up on my GA dashboard.花了一段时间,但事件最终确实出现在我的 GA 仪表板上。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM