Monday 30 July 2018

Google Analytics using React Web / Cordova

I have made an app using React (Web) and bundled it using Cordova.

I am using a plugin called 'react-ga' for tracking Google Analytics.

I initialise react-ga when the app is run using:

ReactGA.initialize('my-ga-uid', { debug: true, cookieDomain: 'auto' })

And create an event using something like:

ReactGA.event({
  category: 'Test',
  action: 'Test button pressed event.'
})

or,

ReactGA.set({ location.pathname })
ReactGA.pageview(location.pathname)

The analytics work fine in the browser and on dev builds, however when I bundle a build for iOS or Android, the analytics don't seem to be tracked?

Is there something wrong with my code? Do I need to initialise something else? Do I need a cordova plugin instead (although I want analytics to still work in a web browser)?



from Google Analytics using React Web / Cordova

No comments:

Post a Comment