React Native: GoogleAnalytics

Setup

  1. Sign up for Google Analytics and create a new mobile propertyarrow-up-right.

  2. Install the following npm package: GoogleAnalyticsBridgearrow-up-right.

  3. For each mobile platform (Android or iOS), you need to follow its corresponding manual installationarrow-up-right.

  4. Install the target:

     npm install --save @redux-beacon/react-native-google-analytics

Usage

import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge';
import GoogleAnalytics from '@redux-beacon/react-native-google-analytics';

// Create or import an events map.
// See "getting started" pages for instructions.

const trackingId = 'UA-12345678-1' // replace with your own
const ga = GoogleAnalytics(trackingId, GoogleAnalyticsTracker);

const gaMiddleware = createMiddleware(eventsMap, ga);

Additional Settings

You also have access to some additional settingsarrow-up-right from the underlying react-native-google-analytics-bridge. These settings can be used to:

  • Disable your app from sending events to Google Analytics

  • Disable your app from tracking events altogether - this can be used to give your users control over opting in/out from analytics.

These settings can be applied as follows:

Event Definitions

Don't see your event listed? Please submit a pull request to the Redux Beacon repositoryarrow-up-right with the missing event. Use the source of the existing event-helpers to guide your work. If you need any support feel free to make the pull request with all you're able to do. We can fill in the gaps from there.

screenView

Docs:

event

Docs:

purchase

Docs:

timing

Docs:

https://developers.google.com/analytics/devguides/collection/ios/v3/usertimingsarrow-up-right

socialInteraction

Docs:

https://developers.google.com/analytics/devguides/collection/ios/v3/socialarrow-up-right

user

Docs:

https://developers.google.com/analytics/devguides/collection/ios/v3/user-idarrow-up-right

client

Docs:

https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientIdarrow-up-right

exception

Docs:

https://developers.google.com/analytics/devguides/collection/ios/v3/exceptionsarrow-up-right

Last updated