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.
Before you begin
If you haven't already added Analytics to your app, in your
Activity, intialize the
private FirebaseAnalytics mFirebaseAnalytics;
// ...// Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
After you have created a
FirebaseAnalytics instance, you can use it to log
events with the
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
- Prescribed parameters: see the
The following example demonstrates how to log a suggested
Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image"); mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
In addition to the prescribed parameters, you can add the following parameters to any event:
Custom parameters: Custom parameters can be registered for reporting in your Analytics reports. They can also 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.
VALUEis 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:
Bundle params = new Bundle(); params.putString("image_name", name); params.putString("full_text", text); mFirebaseAnalytics.logEvent("share_image", params);
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:
adb shell setprop log.tag.FA VERBOSE adb shell setprop log.tag.FA-SVC VERBOSE adb logcat -v time -s FA FA-SVC
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:
- In the Firebase console, open your project.
- 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.