React-ga: Debug shows that ReactGA is being called but no data reaches Google Analytics

Created on 13 Feb 2019  路  3Comments  路  Source: react-ga/react-ga

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.

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:

ReactGA.initialize('UA-XXXXXXX-2', {
    debug: true,
    titleCase: false,
});
ReactGA.ga('set', 'checkProtocolTask', null);
ReactGA.pageview('/popup.html');

All 3 comments

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);
  }

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');
Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewmclagan picture andrewmclagan  路  3Comments

TomasVink picture TomasVink  路  3Comments

CJ99 picture CJ99  路  3Comments

astroana picture astroana  路  5Comments

olalonde picture olalonde  路  3Comments