Christian Brevik

Google Analytics on React Native

December 30, 2015

Over the Christmas weekend I decided to sit down and finally write a React Native bridge for Google Analytics. The pure JavaScript variant already exists as an excellent library made by lwansbrough, so why make a native bridge?

The key difference is that with this native bridge you get a lot of the metadata handled automatically by the Google Analytics library. This will include the device UUID, device model, viewport size, OS version, etc. With the pure JavaScript variant you will have to pull this information out via a native bridge from the device (e.g. with rebeccahughes’ DeviceInfo in order to track it.

With the native library you will only have to send in a few parameteres when tracking, e.g:

const GoogleAnalytics = require('react-native-google-analytics-bridge')

GoogleAnalytics.trackScreenView('Home')
GoogleAnalytics.trackEvent('testcategory', 'testaction')

Visit the Github repo for an installation guide and API.


Christian Brevik

Hi there! I'm a developer living in Trondheim. Find me on Github or Twitter.