Firebase analytics events android

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.

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.

2. Suggested Events (Pre-Defined Events)

Good 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.

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.

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.

After 15-minute event is uploaded.

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.

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.

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:

Now open up Analytics debug view window

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.

And you can see Event properties as well.

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.

Источник

Log Events

Events provide insight on what is happening in your app, such as user actions, system events, or errors.

Analytics automatically logs some events for you; you don’t need to add any code to receive them. If your app needs to collect additional data, you can log up to 500 different Analytics Event types in your app. There is no limit on the total volume of events your app logs. Note that event names are case-sensitive and that logging two events whose names differ only in case will result in two distinct events.

Читайте также:  Живые фотообои для андроид

Prerequisite

If you haven’t already added Analytics to your app, in your Activity , intialize the com.google.firebase.analytics.FirebaseAnalytics object:

Log events

After you have created a `FirebaseAnalytics` instance, you can use it to log events with the logEvent() method.

To help you get started, the Firebase SDK defines a number of suggested events that are common among different types of apps, including retail and ecommerce, travel, and gaming apps. To learn more about these events and when to use them, browse the Events and properties articles in the Firebase Help Center. Note: To get the maximum detail in reports, log the suggested events that make sense for your app and their prescribed parameters. This also ensures that you benefit from the latest app reporting features as they become available.

You can find implementation details for suggested event types in the following locations:

The following example demonstrates how to log a suggested SELECT_CONTENT Event:

In addition to the prescribed parameters, you can add the following parameters to any event:

  • Custom parameters: Custom parameters are not represented directly in your Analytics reports, but they can be used as filters in audience definitions that can be applied to every report. Custom parameters are also included in data exported to BigQuery if your app is linked to a BigQuery project.
  • VALUE parameter: VALUE is a general purpose parameter that is useful for accumulating a key metric that pertains to an event. Examples include revenue, distance, time, and points.

If your application has specific needs not covered by a suggested event type, you can log your own custom events as shown in this example:

View events in the Android Studio debug log

You can enable verbose logging to monitor logging of events by the SDK to help verify that events are being logged properly. This includes both automatically and manually logged events.

You can enable verbose logging with a series of adb commands:

This command displays your events in the Android Studio logcat, helping you immediately verify that events are being sent.

View events in the dashboard

You can view aggregrated statistics about your events in the Firebase console dashboards. These dashboards update periodically throughout the day. For immediate testing, use the logcat output as described in the previous section.

You can access this data in the Firebase console as follows:

  1. In the Firebase console, open your project.
  2. Select Analytics from the menu to view the Analytics reporting dashboard.

The Events tab shows the event reports that are automatically created for each distinct type of event logged by your app. Read more about the Analytics reporting dashboard in the Firebase Help Center.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Источник

Log Events

Events provide insight on what is happening in your app, such as user actions, system events, or errors.

Google Analytics automatically logs some events for you; you don’t need to add any code to receive them. If your app needs to collect additional data, you can log up to 500 different Analytics event types in your app. There is no limit on the total volume of events your app logs. Note that event names are case-sensitive and that logging two events whose names differ only in case will result in two distinct events.

Читайте также:  Как отправить письмо gmail android

Before you begin

Before you can use Google Analytics, you need to:

Register your Unity project and configure it to use Firebase.

If your Unity project already uses Firebase, then it’s already registered and configured for Firebase.

If you don’t have a Unity project, you can download a sample app.

Add the Firebase Unity SDK (specifically, FirebaseAnalytics.unitypackage ) to your Unity project.

Note that adding Firebase to your Unity project involves tasks both in the Firebase console and in your open Unity project (for example, you download Firebase config files from the console, then move them into your Unity project).

Log events

After you have initialized the Firebase.Analytics.FirebaseAnalytics module, you can use it to log events with the LogEvent() method.

To help you get started, the Analytics SDK defines a number of suggested events that are common among different types of apps, including retail and ecommerce, travel, and gaming apps. To learn more about these events and when to use them, browse the Events and properties articles in the Firebase Help Center.

You can find implementation details for suggested event types in the following locations:

  • Suggested events: see the list of Event constants.
  • Prescribed parameters: see the list of Parameters constants.

The following example demonstrates how to log a suggested SELECT_CONTENT Event:

In addition to the prescribed parameters, you can add the following parameters to any event:

Custom parameters: Custom parameters are not represented directly in your Analytics reports, but they can be used as filters in Audience definitions that can be applied to every report. Custom parameters are also included in data exported to BigQuery if your app is linked to a BigQuery project.

VALUE Parameter: VALUE is a general purpose parameter that is useful for accumulating a key metric that pertains to an Analytics Event. Examples include revenue, distance, time and points.

If your application has specific needs not covered by a suggested Analytics Event type, you can log your own custom Analytics Events as shown in this example:

View events in the log output

Android

You can enable verbose logging in the Android Studio Debug Log, to help verify that events are being logged properly by the SDK. This includes both automatically and manually logged events.

You can enable verbose logging with a series of adb commands:

This command displays your events in the Android Studio logcat, helping you immediately verify that events are being sent.

Events are logged to the console, and can be viewed while running the app through XCode.

View analytics events in the dashboard

You can view aggregrated statistics about your Analytics Events in the Firebase console dashboards. These dashboards update periodically throughout the day. For immediate testing, use the logcat output as described in the previous section.

To access this data in the Firebase console:

  1. In the Firebase console, open your project.
  2. Select Analytics from the menu to view the Analytics reporting dashboard.

The Events tab shows the event reports that are automatically created for each distinct type of Analytics Event logged by your app. Read more about the Analytics reporting dashboard in the Firebase Help Center.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Источник

Оцените статью