How to set up analytics on React Native for iOS How to set up analytics on React Native for iOS reactjs reactjs

How to set up analytics on React Native for iOS


I am the author of a Google Analytics package for React Native: https://github.com/idehub/react-native-google-analytics-bridge

Since it is a pretty simple native bridge to the official Google Analytics libraries, it should not give you any issues related to the platform. Also, it will handle a lot of the metadata automatically, like the device UUID, device model, viewport size, OS version etc.

Because of that last part, the calls can be pretty simple, like tracking a new screen view:

import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge';let tracker = new GoogleAnalyticsTracker('UA-12345-1');tracker.trackScreenView('Home')

Or an event:

tracker.trackEvent('testcategory', 'testaction');


I'm the author of react-native-google-analytics -- the problem with it has been with React Native's lack of support for GIF data in XHR responses on iOS 7. I'm still trying to figure out if the problem people are experiencing is still limited to iOS 7. The bug was reported as fixed by the RN team for iOS > 7, however if that is not the case then there must be a regression. Tracking for the React Native issue is here: https://github.com/facebook/react-native/issues/1780

If you have any other questions regarding the module specifically, please don't hesitate to ask on GitHub!


I just set up mixpanel with this package:https://github.com/davodesign84/react-native-mixpanel

And then I have something like this in my main.js file that holds all my view components:

componentWillMount: function() {    this.loadData(this.setDataState);    // not sure if this is the best way to do it, but whatever    Mixpanel.identify(DeviceInfo.getUniqueID());    Mixpanel.set("$name", DeviceInfo.getDeviceName());    Mixpanel.track("App Loaded");}

And then in my view.js that renders a component with data, I have something like this:

componentWillMount: function() {    Mixpanel.trackWithProperties("Definition Viewed",{word:this.state.word});}

And then I also call mixpanel when a users adds/deletes data.

After all this, I just noticed that fabric does analytics so I will probably migrate to that because I use to to manage beta testers and its awesome so it'll be nice to have everything in 1 place