16

I am trying to add Firebase Analytics (FA) to my react-native app.

Actually, I didn't find a problem to put Google Analytics (GA) using this library expo-analytics.

But apparently Firebase analytics is more powerful and it is really built for mobile apps. That is why I wanted to use it in my application but the problem is that :

I am using Expo and I cannot detach my app to add the json config files.

So my question is: is there a way to have Firebase Analytics with Expo and react-native without detach?

Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
Ayyoub
  • 1,135
  • 13
  • 34

2 Answers2

23

The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. This means that it is limited to the Firebase products that are available to web developers, which (since September 2019) includes Google Analytics for Firebase (the new name for Firebase Analytics).

Have a look at the Firebase documentation to learn how to get started with analytics on the web.


Previous, and now outdates, answer below. I'm leaving it here for reference for how.

The default binding that Expo has for Firebase is based on the Firebase JavaScript SDK. This means that it is limited to the Firebase products that are available to web developers, which unfortunately doesn't include Google Analytics for Firebase (the new name for Firebase Analytics).

This means that you'll have to rely on a third party library for binding other Firebase features into your Expo app. And since those libraries are bridging to the native Android and iOS SDKs of Firebase, there is no way to use them without detaching/ejecting.

Also see:

Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
  • Is this answer up-to-date? There is a Web section in docs of Firebase Analytics. https://firebase.google.com/docs/analytics/get-started – Emre Sülün Sep 28 '19 at 13:26
  • 1
    Good find Emre. Web analytics was just released on Firebase this weak, so quite some answers may be outdated. – Frank van Puffelen Sep 28 '19 at 15:11
  • 1
    Unfortunately the web implementation requires IndexedDB which is not available in an Expo environment, so you can‘t use it right now. See the following feature request for further information: https://github.com/firebase/firebase-js-sdk/issues/2244 – Jonas Oct 19 '19 at 11:19
  • 1
    Any update on how to integrate Firebase Analytics with Expo? The issue mentionned above is not making things work. – Poptocrack Dec 05 '19 at 14:48
  • 3
    It looks like it's been finally added to Expo so that published builds have proper Firebase Analytics support (but not when running in Expo): https://twitter.com/notbrent/status/1236450369904848896 – David Airapetyan Mar 08 '20 at 06:29
1

Check out a detailed answer of how to integrate Firebase Analytics into Expo here: https://github.com/firebase/firebase-js-sdk/issues/2244#issuecomment-558621111

In short:

You can integrate Firebase Analytics into Android App using android.googleServicesFile field. Works at least for SDKs 33, 34, 35.

For iOS App ios.googleServicesFile field is missing in the Expo Docs but still can be used for Firebase Analytics. Works at least for SDK 34. Issue in Expo repo was created: https://github.com/expo/expo/issues/6379