To integrate FirebaseAnalytics in Expo project follow below steps

Step 1: Run below command
expo install expo-firebase-analytics

Step 2: Create a project on firebase console and download
GoogleService-Info.plist and google-services.json file

Link: https://console.firebase.google.com
Add the above two files in the projects root directory.

Steps 3: Add below configuration in App.json file

{
“expo”: {
“android”: {
“package”: “com.mypackage.myapp”,
“googleServicesFile”: “./google-services.json”
},
“ios”: {
“bundleIdentifier”: “com.mypackage.myapp”,
“googleServicesFile”: “./GoogleService-Info.plist”
}
},
}

Step 4: Import firebase analytics

import * as Analytics from 'expo-firebase-analytics';

Step 4: Add custom events
const logEvents = (action,event_name,screen_name,purpose) => {
await Analytics.logEvent(action, {
name: event_name,
screen: screen_name,
purpose: purpose,
});
}
For Example -

const logEvents = () => {
await Analytics.logEvent('ButtonTapped', {
name: 'settings',
screen: 'profile',
purpose: 'Opens the internal settings',
});
}

--

--