Tracking Conversions with Firebase Analytics

Step 1: Define Conversion Events

Identify the key actions you want to track as conversions. Common conversion events include:

  • Sign-Ups: When a user registers for your app.
  • Purchases: When a user completes a purchase.
  • Button Clicks: When a user clicks on a specific call-to-action button.
  • Feature Engagement: When a user engages with a particular feature in your app.

Step 2: Log Conversion Events

Use the Firebase Analytics SDK to log these events. Here are examples for different platforms:

For Android

import com.google.firebase.analytics.FirebaseAnalytics;

// Initialize Firebase Analytics
FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

// Log a sign-up event
Bundle params = new Bundle();
params.putString("method", "email");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SIGN_UP, params);

// Log a purchase event
Bundle purchaseParams = new Bundle();
purchaseParams.putString("transaction_id", "T12345");
purchaseParams.putDouble("value", 9.99);
purchaseParams.putString("currency", "USD");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ECOMMERCE_PURCHASE, purchaseParams);

This code snippet uses the Firebase Analytics library for Android to log events. It initializes Firebase Analytics and then logs two events: a sign-up event with the method of sign-up (email), and a purchase event with the transaction ID, value, and currency.

For iOS

import Firebase

// Initialize Firebase Analytics
let analytics = Analytics.self

// Log a sign-up event
analytics.logEvent(AnalyticsEventSignUp, parameters: [
AnalyticsParameterMethod: "email" as NSObject
])

// Log a purchase event
analytics.logEvent(AnalyticsEventEcommercePurchase, parameters: [
AnalyticsParameterTransactionID: "T12345" as NSObject,
AnalyticsParameterValue: 9.99 as NSObject,
AnalyticsParameterCurrency: "USD" as NSObject
])

The code snippet uses Firebase Analytics to log events. The first event logs a sign-up event with the method of sign-up (email), while the second event logs a purchase event with the transaction ID, value, and currency.

For Web

import { logEvent } from "firebase/analytics";

// Log a sign-up event
logEvent(analytics, 'sign_up', {
method: 'email'
});

// Log a purchase event
logEvent(analytics, 'purchase', {
transaction_id: 'T12345',
value: 9.99,
currency: 'USD'
});

The code snippet logs events using Firebase Analytics. The first event logs a sign-up event with the method of sign-up (email), while the second event logs a purchase event with the transaction ID, value, and currency.

Step 3: Set Up Conversion Tracking in Firebase Console

  • Go to the Events Section: In the Firebase console, navigate to Analytics > Events.
  • Mark Events as Conversions: Select the events we want to track as conversions and mark them as conversion events. This can be done by toggling the conversion switch next to the event name.

Conversion Tracking with Firebase

Tracking conversions is essential for understanding how effectively our app meets its goals and drives user actions. Firebase provides robust tools for conversion tracking, enabling us to measure key events, optimize user journeys and improve our app’s performance.

In this article, We will learn about Conversion Tracking with Firebase by setting up conversion tracking in Firebase in detail.

Similar Reads

What is Conversion Tracking?

Conversion tracking involves measuring specific actions that users take within our app that are valuable to our business. These actions known as conversions can include purchases, sign-ups or any other goal that indicates user engagement and success....

Setting Up Firebase for Conversion Tracking

Step 1: Create a Firebase Project...

Tracking Conversions with Firebase Analytics

Step 1: Define Conversion Events...

Analyzing Conversion Data

Firebase Analytics Dashboard...

Conclusion

Conversion tracking with Firebase is a powerful way to measure and optimize key user actions within your app. By setting up and logging custom events, marking them as conversions, and analyzing the data through the Firebase console, you can gain valuable insights into user behavior and make data-driven decisions to enhance your app’s performance....