What are Events in Firebase Analytics? (And How to Use)

It’s not about the wedding event of your crush where you’ll get depressed after looking at your gorgeous girl. 👸

But it’s an event of Firebase Analytics that collects data about any interactions with your app that you can measure.

Quick Jumps

3 Types of Firebase Analytics Events

Firebase Analytics can capture a lot of events automatically for you, but the majority of the events belong to three types of events:

1. Automatic Events

As the name suggests, these are the events that are measured automatically for you even if you don’t do anything at call.

automaic events

You can see all the automatic events from the official website.

2. Suggested Events (Pre-Defined Events)

suggested eventsGood developers know automatic events aren’t enough to make full use of the app.

In the suggested events, you can use:

  • Games
  • Retail/eCommerce
  • Jobs
  • Education
  • Travel
  • Local Deals
  • Real Estate

For example, you want to see when a user submits their payment information; you can use add_payment_info event that falls in the Real Estate event category.

Retail Events in Firebase

I recommend you to use one of these predefined events instead of creating a new (custom) one because Firebase understands the context around these predefined events much better.

3. Custom Events

Experienced developers commonly use custom events since the ultimate freedom is provided.

You can collect information about any events you wish you could have tracked.

When do you need custom events?

When the events are not mentioned in the automatic and suggested events.

You are always welcome to use Firebase API with the custom name.

Firebase makes it very easy for you. It’s a single line of code that you have to write.

Just supply the name and optionally supply any of the parameters that can contextualize that event to give you more context around what’s going on in your app.

Watch the Video Tutorial

In this video, you’ll learn how you can make a custom event and also log it into Logcat and Firebase Console.

How to Implements Events Into your App

There are many ways to implements events and parameters in Firebase analytics, but I have some best practices that I recommend you.

You’re going to implement a custom event, but by completing this tutorial, you can easily handle suggested events as well.

1. Create/Open Android Studio Project

First of all, create a new project or open an existing project in the Android Studio.

2. Add Firebase to your project

Then add Firebase to your project if you didn’t add previously. Don’t know how? Watch the video.

3. Add Analytics SDK to Your Project

  1. Add below dependency to your build. Gradle (app) File.

2. Declare FirebaseAnalytics object at the beginning of the MainActivity.java

3. Initialize this object inside MainAvtivity.java onCreate() method.

Now you have analytics up and running into your app.

In fact, if you do nothing at this point.

You are about to start some data in the Firebase Console: things like overall usage, user engagement, revenue, attention, etc.

4. Start Logging Events

Now you have initialized the instance of FirebaseAnalytics.

Now you can start the event with logEvents() method.

These events are recommended for all types of app and other events are specifically related to the businesses.

You have to send suggested events along with their parameters just to increase maximum details in the reports. Who knows maybe it might be helpful in the near future.

The below code calls the SELECT_CONTENT event whenever any of the users click on a particular item in your app.

FirebaseAnalytics.Event ( Suggested Events Reference ) is the predefined constant that is available in our SDK and this documentation ( Prescribed parameters of Events Reference ) helps you to understand which parameter goes with which events.

And if your application needs do not fulfill with the suggested event then you can use custom events with the help of the below code.

5. Do Some Code

To make tutorial simple, I’m adding a button in activity_main.xml file

Here is the MainActivity.java file where I logged a custom event.

Note: Here is the official source code sample. You can download and analyze for better understanding.

Github Events

6. Run the App

Now just run the app.

Now when you click on the button Firebase Analytics shows you that your event is scheduled for approximately 15 minutes.

In your case, maybe it’s time is low or maybe high.

It depends on the Android OS workload.

I’m using the emulator that’s why time is too much.

Logging Event in Console

After 15-minute event is uploaded.

upload Event successfull

7. View Events in Firebase Dashboard

Here comes the fun part.

You can access the data in the event console.

Here you can see the event report that is automatically reported for each action occurring in your app.

Event console

Afterward, you can’t see the progress right now because of the Dashboard updates on a daily basis (every 24 hours).  You can check immediately using Logcat output as below.

After 24 hours by clicking on particular events. You can watch the complete detailed information about that event like as shown in the image below.

analytics EventsPerSession demographics location

8. View Events in Debug View

So you don’t want to wait 24 hours?

Don’t worry you can check your event report in the Debug View window as well.

In order to watch events in the debug view window, you have to implement a couple of things.

As described in support.google.com add below code in the terminal window of the android studio.

In my case I’m getting this error “adb’ is not recognized as an internal or external command”

I find the solution on StackOverflow and you can add the path in the environment variable with the help of java.com

Why I get the Error? 

In the newer version of Android Studio  “%USERPROFILE%\AppData\Local\Android\sdk\platform-tools”  is not available. Yeah I know it’s a bug. You can add this path manually in the environment variable see How to add the path in the environment variable depending on your Windows.

When a path is added successfully then you run the below cmd again.

And it looks like this:

cmd executes in terminal window

Now open up Analytics debug view window

Event in DebugView

I’ve added a custom event in my demo app, similarly, you can add a suggested (pre-defined event) in the same way.

Similarly, you can see parameters by clicking on any events.

Event in DebugView parameters

And you can see Event properties as well.

Event in DebugView properties

Now it’s your turn. How will you use the event knowledge in your app? Have a question of any type from an experienced Android developer? Ask below without any hesitation.

3 thoughts on “What are Events in Firebase Analytics? (And How to Use)”

  1. Well firebase seems to have real good features. However, does
    firebase spark (free plan) have the option to schedule mails like in google
    analytics? And can i create reports like in google analytics? for example i would want to create a report that has daily users, funnel that i have created, retention etc and schedule a mail everyday. Can i do this in firebase?

Comments are closed.