[我正在尝试让GA跟踪我的所有被React Router v4更改的页面。
我使用库看此代码:react-ga
history.listen(location => {
// ReactGA.set({ page: location.pathname })
// ReactGA.pageview(location.pathname)
})
但是我认为这不会记录第一页。
我看到了,但是我不知道如何在我的网站上进行设置
https://github.com/react-ga/react-ga/wiki/React-Router-v4-withTracker
我的index.js看起来像这样
ReactDOM.render(
<Provider routingStore={routingStore} domainStores={DomainStores} uiStores={uiStores}>
<Router history={history}>
<ErrorBoundary FallbackComponent={ErrorFallbackComponent}>
<StripeProvider apiKey={stripeKey}>
<AppContainer />
</StripeProvider>
</ErrorBoundary>
</Router>
</Provider>
,
document.getElementById('app')
);
然后在“ appConainter”中,我有“ Switch”及其路由)>
<Switch>
<Route
exact
path="n"
component={}
/>
</Switch>
我正在尝试让GA跟踪由React Router v4更改的所有页面。我使用库查看了以下代码:react-ga history.listen(location => {// ReactGA.set({page:location ....
您需要将其包括在AppContainer
组件中: