How to Set Up App Analytics for Android and iOS with Firebase

How to Set Up App Analytics for Android and iOS with Firebase

If you have an iOS or Android app, a crucial first step that you need to cover is app analytics. App analytics in Android or iOS is extremely useful in uncovering the key events within your app, and will give you an insight on which features your users are using the most. You can also track exactly how much revenue your app is making when you have app analytics set up.

Analytics can be complicated (hint: scary!) task, but fortunately we can easily set it up using Google’s Firebase SDK. In this article, we’re going to discuss that and approach it with the following:

  1. What is Firebase and how can you use it for conversion tracking?
  2. Defining custom events in Firebase
  3. Tracking conversion transaction values in Firebase
  4. Displaying events in Firebase
  5. Setting events as conversions in Firebase

What is Firebase and How Can It Help You with Conversion Tracking?

In a nutshell, Firebase is a platform that allows users to build web and mobile applications without having to right backend code. It offers a ton of features that programmers would appreciate. Some of them are:

  • Cloud Storage
  • Hosting
  • Realtime Database
  • Authentication
  • Performance Monitoring
  • Test Lab
  • Google Analytics
  • A/B Testing
  • Remote Config
  • Dynamic Testing

Since we’re discussing conversion tracking, let’s talk about Firebase’s Google Analytics features. Being a Google Product, Firebase offers a free and unlimited measurement tool for your app. You can define up to 500 distinct events to help you understand how your user behaves and interacts with your app.

Standard Events in Firebase

Firebase collects 20+ events by default. You can see the full list here. The most notable standard events for marketing are:

  • ad_click: when a user clicks on an ad
  • app_remove: when a user uninstalls an app
  • first_open: when someone opens the app for the first time after installing or reinstalling it. This is your activation metric.
  • in_app_purchase: when someone purchases through iTunes or Google Play (must be processed by the Google App)

If you want to track custom conversions, then you need to log your own events within Firebase, which we’ll discuss fully in later chapters.

At this point, it is required to have Firebase installed on your apps. Since Firebase is a Google Product, you can easily find documentation on how to do that:

Tracking Transaction Values in Firebase

Aside from tracking standard events, Firebase’s Google Analytics feature can also help you track the transactions happening within your app (especially if you’re not using Google Play for transactions). This is an example of transaction values for an event that we’re tracking for one of our clients.

tracking conversion values in Firebase

In this example, we’re tracking the number of people who have added funds to their account with 7/11. Since this client of ours have multiple cash in channels (banks, online payments, etc), we can clearly see which channel our users prefer. This allows users to give recommendations to their product and marketing teams.

Events versus Conversions

In this article, we talk about events and conversions. For the sake of discussion, these terms are not interchangeable and mean different things:

Events are any activities that are happening within your app that you want to track.
Conversions are events that you consider KPIs (key performance indicators) in your organization/company.

Now that’s out of the way, let’s set up custom events in Firebase.

Defining Custom Events in Firebase

To track transaction values in Firebase, you would need to set up custom events first. Since you can track up to 500 events of your own, it’s best to have a clear list of actions that you want to be tracked in your app. You can make a simple checklist to do this.

Once you have your list, you can now proceed with installing these events in Firebase.

Installing Custom Events in Firebase

I’m going to preface that this part requires dev experience, but unless the work is outsourced to you (i.e. you don’t have access to the developer), then you should be fine.

Custom event tracking in Android

Tracking events in Firebase requires you to track classes within the application. The event is tracked using the logEvent() method from the FirebaseSDK. Additionally, you can either track the event without any parameters or choose to add your own.

The logEvent() method comprises of 2 parameters: name and params. The name parameter is a String that represents the name of the event. It should be composed only of letters and underscores. Remember this format when declaring your name parameter. The params is a Bundle object that represents the parameters of the event.

Logging an event without any parameters is straightforward, like so:

firebaseAnalytics.logEvent (“payment_complete”, null);

In the example above, payment_complete is the name parameter, while null is the object. This line of code will log when the event associated with payment_complete is executed.

In most cases however, you’d need more than just logging the events in your app. Fortunately, Firebase allows us to set multiple parameters within an event. This is done through the Bundle instance. Using the example above, we can set multiple parameters in payment_complete with:

Bundle bundle = new Bundle();
bundle.putString(“date”, “2018-07-12”);
bundle.putString(“payment_method”, “Credit Card”);
bundle.putInt(“amount”, “301”);
firebaseAnalytics.logEvent(“payment_complete”, bundle);

In the example above, the event payment_complete will have 3 parameters: date, payment_method, and amount.

Quick tip: to be able to display amount values in Firebase, you need to use an integer instead of a string parameter. It sounds simple, but don’t forget!

Custom event tracking in iOS

Similar to Android tracking, we will also track custom events in iOS with the logEventWithName() method. We will also use two parameters: name and params as with Android tracking.

Using the same event (payment_complete) above, we can log it in iOS with:

[FIRAnalytics logEventWithName:@”payment_complete” parameters:@ {
@”date”: date,

Displaying Transaction Values in Firebase

It will take a couple of hours before your events are displayed in Firebase. This is because events are batched together over a period of one hour and uploaded together. According to Google, this conserves battery on the users’ device and helps reduce data usage.

But if you want to see whether your raw event data is being logged, you can use Firebase’s DebugView feature. You need to have a development device ready here. Once you test an event/transaction, head over to the DebugView tab. You should see something like this:

The field boxed in red shows the parameters you logged with the event.

After using the DebugView and confirming that the raw event data is being logged and waiting for a few hours, you can now display your events. To do this, you need to go to the Events tab in Firebase’s Analytics section:

log events firebase

You will then see the list of your events, click on the vertical ellipsis icon and select “Edit parameter reporting”:

edit parameter reporting firebase

You will be asked which parameters you would want to display with your event. In this example, we’re going to display the amount parameter, which uses currency as a unit of measurement:

parameter reporting firebase

Once you’re done, click Save. After returning to the dashboard, click on the event. You should now see the amount displayed:

display conversion amount Firebase

Optional: Setting Your Events as Conversions

Custom events are not automatically considered as conversions, but you have the ability to enable them as such. You can have up to 15 events per project as conversions, which excludes the default conversions first_open, in_app_purchase, and ecommerce_purchase.

To do this, go to the Events tab and enable the “Mark as conversion” slider:

mark events as conversion Firebase

Once the event has been marked as a conversion, go to the Conversions tab, where you’ll see the list of your conversions. When you open the conversion, you’ll see where the conversion is being attributed. This is extremely useful if you have multiple traffic sources!

That’s it! You have successfully set up Firebase to track transactions within your app.

Filed Under: Analytics

Tagged With: android tracking, app analytics, firebase, firebase conversion tracking, firebase custom event, firebase installation, how to use firebase, ios tracking

Publish Date

November 12, 2020

Christian Alan Vibar
Senior Growth Manager

Also on Monolith Growth Consulting

Fix your Facebook Tracking Pixel Problems with this 5 Step Audit (for Shopify)

November 12, 2020
Read Now

How to Build & Target the Right Facebook Audience for Your Shopify Store (5 Tips)

November 12, 2020
Read Now

The 5-Step Facebook Pixel Audit to Fix BigCommerce Tracking Problems

November 12, 2020
Read Now
See More Articles