React Native Google Tag Manager
Usage Instructions
Sign up for Google Tag Manager if you haven't already, create a mobile container for each of Android and iOS. Select Legacy for SDK Version. Make a note of your property's tracking Id.
Install the npm package, GoogleAnalyticsBridge, in your project.
For each mobile platform (Android or iOS), you need to follow its corresponding manual installation for GoogleAnalyticsBridge usage.
Import the target, then provide it when creating the middleware:
import { Platform } from 'react-native'; import { GoogleTagManager as GTMBridge } from 'react-native-google-analytics-bridge'; import { GoogleTagManager } from 'redux-beacon/targets/react-native'; const containerId = (Platform.OS === 'ios') ? 'GTM-IOSXXXX' : 'GTM-ANDROID'; const target = GoogleTagManager(containerId, GTMBridge); const analyticsMiddleware = createMiddleware(eventsMap, target);
You need to detect the current platform and give a correct container ID for Google Tag Manager.