我正在尝试在react-ga
挂钩的帮助下启用谷歌分析。
我在github
上关注了他们的文档,我不知道为什么我没有得到任何数据,也不知道如何调试它。我已将此代码粘贴到每个页面上,但我仍然没有得到任何东西,而且我的 Firebase 应用程序中的流配置也是如此。ReactGA.initialize("G-NHW4EP16PN");
import ReactGA from "react-ga";
function App() {
useEffect(() => {
ReactGA.initialize("G-NHW4EP16PN");
ReactGA.pageview(window.location.pathname + window.location.search);
console.log(window.location.pathname);
}, []);
return (
<>
<Suspense fallback={<LoadingWait src={LoadImg} />}>
<Router>
<Sidebar />
<Switch>
<Route component={Overview} path="/" exact={true} />
<Route component={Work} path="/work" />
<Route component={Services} path="/services" />
<Route component={Contact} path="/contact" />
<Route component={PageNotFound} />
</Switch>
</Router>
</Suspense>
</>
);
}
export default App;