我正在尝试添加GA来记录网页匹配。我已经尝试了所有解决方案以使其正常运行,但没有任何进展。
在index.js中
import ReactGA from 'react-ga';
const hist = createBrowserHistory();
ReactGA.initialize('Tracking_Id');
hist.listen(location => {
ReactGA.set({ page: location.pathname }); // Update the user's current page
ReactGA.pageview(location.pathname + location.search); // Record a pageview for the given page
console.log(location.pathname)
});
我的路线是
<Provider store={store}>
<Router history={hist}>
<Route path='/thank-you' component={ThankYou} />
<Route path='/auth' component={AuthLayout} />
<Route exact path='/' component={HomeLayout} />
<Switch>
<PrivateRoute path='/admin' component={Adminlayout} />
</Switch>
</Router>
</Provider>,
请指导我做错了什么。