I'm developing a Chrome extension:
In my manifest I've specified:
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
I then initialize ReactGA as follows in my root component:
ReactGA.initialize('UA-XXXXXXX-2', {
debug: true,
testMode: false,
gaAddress: 'https://ssl.google-analytics.com/ga.js',
});
I then call ReactGA.pageview('/main-view'); inside componentDidMount()
I also use React-Router however I don't think it is the issue preventing requests to GA to go out (assuming that's the issue).
Has anyone encountered an issue like this? I'd appreciate any input.
Isnt working for me either. Nothing in real time data. Nothing after waiting for 24-48 hours.
I see events being fired in the console. Also see network calls to google analytics.
No filters in the dashboard.
Maybe the calls are getting dropped by google because some data is missing in the calls ?
componentDidMount() {
ReactGA.initialize('UA-XXXXXXXX-1',{
debug: this.appData.env === "development",
titleCase: false
});
ReactGA.set({ appVersion: this.appData.version});
ReactGA.set({ page: window.location.pathname });
ReactGA.pageview(window.location.pathname);
}
In my case the issue was appVersion. Because of this https://stackoverflow.com/questions/36508241/how-do-i-set-appversion-for-google-analytics-event-tracking
Now fixed
Hey @velchevski,
I had the same problem when trying to implement GA using this library for a chrome extension. It turns out the problem isn't with this library but with Universal Analytics for chrome extensions in general.
I found a workaround here: https://stackoverflow.com/questions/16135000/how-do-you-integrate-universal-analytics-in-to-chrome-extensions/24165203#24165203
My implementation looked liked this:
ReactGA.initialize('UA-XXXXXXX-2', {
debug: true,
titleCase: false,
});
ReactGA.ga('set', 'checkProtocolTask', null);
ReactGA.pageview('/popup.html');
Most helpful comment
Hey @velchevski,
I had the same problem when trying to implement GA using this library for a chrome extension. It turns out the problem isn't with this library but with Universal Analytics for chrome extensions in general.
I found a workaround here: https://stackoverflow.com/questions/16135000/how-do-you-integrate-universal-analytics-in-to-chrome-extensions/24165203#24165203
My implementation looked liked this: