Skip to main content

Adding Firebase Analytics to your React Native app

Alex Cirstea23 May 20183 min read
Adding Firebase Analytics to your React Native app
			<span style="font-weight: 400;">This article describes how to integrate Google Analytics for Firebase (formerly Firebase Analytics) to a React Native app. </span><span style="font-weight: 400;">In order to do this, you need to use a JavaScript bridge called </span><a href="https://github.com/invertase/react-native-firebase"><span style="font-weight: 400;">RNFirebase</span></a><span style="font-weight: 400;">. &nbsp;</span>

This is lightweight layer sitting on top of native Firebase libraries for both iOS and Android which mirrors the Firebase Web SDK as closely as possible.

Even though the Firebase Web SDK library will work with React Native, it is mainly built for the web and some features are not available. You can find more details on the documentation page, but in summary, RNFirebase offers a faster performance over the web SDK and allows to hook into device SDKs which is not possible with the web SDK.

Here’s a screenshot of some of the features that are available in RNFirebase in comparison to the Firebase Web SDK:

In order to add Firebase to your React Native app, you need to create a Firebase project and then follow the steps for both Android and iOS. Once you have Firebase added to your app, you can start adding custom tracking. The below code examples have been added to the app.js file in my React Native project folder.

1) Setting the current screen name

setCurrentScreen(name)

Sets the current screen name, which specifies the current visual context in your app. This helps identify the areas in your app where users spend their time and how they interact with your app.

Example: firebase.analytics().setCurrentScreen('home');

2) Setting User Properties

setUserProperty(name, value)

Analytics automatically logs some user properties; you don't need to add any code to enable these. If your app needs to collect additional data, you can set up to 25 different Analytics User Properties in your app. You can analyze behaviors of various user segments by applying these properties as filters to your reports.

Example:  firebase.analytics().setUserProperty('userType', 'developer');

Note: This feature must be used in accordance with Google’s Privacy Policy.

3) Logging an Event

logEvent(name, params)

Logs an app event. If your app needs to collect additional data, you can log up to 500 different Analytics Event types in your app. Be aware of automatically collected events.

Example:  firebase.analytics().logEvent("buttonPressed");

DebugView Firebase

Debugging Firebase Analytics

The events recorded are not automatically sent to Firebase. Instead they are cached and periodically sent to the servers. You can however enable debug mode in Firebase for both Android and iOS.

For Android devices you have to run the following command:

adb shell setprop debug.firebase.analytics.app <package_name>

For iOS you have to pass the following argument in Xcode:

-FIRDebugEnabled

After this step, you should be able to see events in the Firebase console under DebugView. At this point you should have default Firebase tracking implemented and also some custom events being logged to your Firebase project.


Suggested content

Measurelab awarded Google Cloud Marketing Analytics Specialisation

At the start of the year, if you’d asked us whether Measurelab would be standing shoulder to shoulder with Europe’s biggest consultancies by September, we would've been surprised. Not because we don't believe in ourselves, but because these things feel so distant - until suddenly, they’re not. So, here it is: we’ve been awarded the Marketing Analytics Services Partner Specialisation in Google Cloud Partner Advantage. What’s the big deal? In Google’s own words (with the obligatory Zs): “Spec

Will Hayes11 Sept 2025

BigQuery AI.GENERATE tutorial: turn SQL queries into AI-powered insights

BigQuery just got a major upgrade, you can now plug directly into Vertex AI using the new AI.GENERATE function. Translation: your analytics data and generative AI are now best friends, and they’re hanging out right inside SQL. That opens up a whole world of new analysis options for GA4 data, but it also raises some questions: * How do you actually set it up? * What’s it good for (and when should you avoid it)? * Why would you batch the query? Let’s walk through it step by step. Step 1: H

Katie Kaczmarek3 Sept 2025

How to start forecasting in BigQuery with zero training

If you’d told me five years ago that I’d be forecasting product demand using a model trained on 100 billion time points… without writing a single line of ML code… I probably would’ve asked how many coffees you’d had that day ☕️ But its a brand new world. And it’s possible. Let me explain What is TimesFM? TimesFM is a new foundation model from Google, built specifically for time-series forecasting. Think of it like GPT for time, instead of predicting the next word in a sentence, it predicts t

Katie Kaczmarek14 Jul 2025