It’s possible to use React Native and install Firebase GTM. This is great because no documentation on this topic exists at the moment. Below is a summary. Our goal is to provide a bit of structure around installation because we’re combining several different technologies and, therefore, it’s easy to become disorganized.
Step 1: Install Firebase
- Install React Native Firebase from NPM in the project root.
- npm install –save react-native-firebase
- Create a Firebase Project and App
- iOS specific directions
- Android specific directions
Step 2: Install Firebase GTM
- iOS
- Install Cocopods
- Add the below to the podfile.
- pod ‘GoogleTagManager’, ‘~> 6.0’
- Run ‘pod install’
- Create GTM Container and download default container.
- Place default container into a created ‘container’ folder.
- <PROJECT_ROOT>/container/GTM-
XXXXXX.json - Note: This has to be an actual folder with the exact name—otherwise GTM will not be installed correctly.
- <PROJECT_ROOT>/container/GTM-
- Android
- Add the below under ‘dependencies’ within the app gradle.
- compile ‘com.google.android.gms:play-
services-tagmanager:11.0.4′
- compile ‘com.google.android.gms:play-
- Create GTM Container and download default container.
- Place default container into a created ‘containers’ folder.
- app/main/assets/containers
- Note: This has to be an actual folder with the exact name—otherwise GTM will not be installed correctly.
- Add the below under ‘dependencies’ within the app gradle.
Step 3: Add Analytics Code
We can now add JavaScript code to our React Native app that will send data to Firebase GTM. We do this by calling the below object:
firebase.analytics()
We can send data to Firebase GTM with the below:
firebase.analytics().logEvent(
Here’s the reference for more info.
This information is sent to Firebase GTM and, therefore, Firebase Analytics automatically. We should see this information in the Firebase Analytics StreamView. Once we have Google Analytics tags setup in Firebase GTM, we should see this information appear in Google Analytics Real-Time reports as well.