Learn how to integrate Firebase Analytics into your Android/iOS app, log custom events, debug them, and review insights in the Firebase Console with our step-by-step guide.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Set Up Firebase in Your Project
Before you can track custom events in Firebase Analytics, you need to set up Firebase in your app. Follow these steps:
google-services.json file for Android or GoogleService-Info.plist file for iOS from the Firebase Console and integrate it into your project.
Step 2: Add Firebase SDK to Your App
You need to add the Firebase SDK to your app to enable analytics. The following snippets show how you can do this for both Android and iOS:
For Android:
// Open your app's build.gradle file and add the following dependencies:
dependencies {
// Add the dependencies for the Firebase SDKs you want to use.
// For example, to use Firebase Analytics, add:
implementation 'com.google.firebase:firebase-analytics:21.0.0'
}
For iOS:
// Open your Podfile and add the FirebaseAnalytics pod dependency:
pod 'Firebase/Analytics'
pod install in your terminal for iOS or sync your Gradle files for Android.
Step 3: Initialize Firebase in Your Project
Make sure Firebase is initialized once your app starts. Here's how you can do this:
For Android:
@Override
public void onCreate() {
super.onCreate();
// Initialize Firebase
FirebaseApp.initializeApp(this);
}
For iOS:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(\_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize Firebase
FirebaseApp.configure()
return true
}
}
Step 4: Log Custom Events in Firebase
Now that Firebase is set up, you can log custom events to track specific user interactions. Use the following method to log custom events:
For Android:
// Obtain the FirebaseAnalytics instance.
FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
// Log a custom event.
Bundle params = new Bundle();
params.putString("image_name", "example_name");
params.putString("full\_text", "Example full text");
mFirebaseAnalytics.logEvent("share\_image", params);
For iOS:
import Firebase
// Log a custom event.
Analytics.logEvent("share\_image", parameters: [
"image_name": "example_name",
"full\_text": "Example full text"
])
Step 5: Debug and Verify Custom Events
To ensure your custom events are logged correctly, you can use the built-in debugging utilities from Firebase:
For Android:
FA to view Firebase Analytics logs.For iOS:
Step 6: View Events in Firebase Console
Once events are set up and verified in your app, you can view them on the Firebase Console under the Analytics dashboard:
By following these steps, you can successfully track custom events in Firebase Analytics to gain insights into user behavior in your app.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.