If you're creating a new Firebase project, enableGoogle Analyticsduring the project creation workflow.
If you're using an existing Firebase project that doesn't haveGoogle Analyticsenabled, go to theIntegrationstab of yoursettings>Project settingsto enable it.
When you enableGoogle Analyticsin your project, your Firebase apps are
linked toGoogle Analyticsdata streams.
Add theAnalyticsSDK to your app
In yourmodule (app-level) Gradle file(usually<project>/<app-module>/build.gradle.ktsor<project>/<app-module>/build.gradle),
add the dependency for theAnalyticslibrary for Android. We recommend using theFirebase Android BoMto control library versioning.
dependencies{// Import theBoMfor the Firebase platformimplementation(platform("com.google.firebase:firebase-bom:34.4.0"))// Add the dependency for theAnalyticslibrary// When using theBoM, you don't specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-analytics")}
By using theFirebase Android BoM,
your app will always use compatible versions of Firebase Android libraries.
(Alternative)
Add Firebase library dependencies without using theBoM
If you choose not to use theFirebase BoM, you must specify each Firebase library version
in its dependency line.
Note that if you usemultipleFirebase libraries in your app, we strongly
recommend using theBoMto manage library versions, which ensures that all versions are
compatible.
dependencies{// Add the dependency for theAnalyticslibrary// When NOT using theBoM, you must specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-analytics:23.0.0")}
Declare thecom.google.firebase.analytics.FirebaseAnalyticsobject at the
top of your activity:
After you have created aFirebaseAnalyticsinstance, you can begin to log
events with thelogEvent()method.
Certain events arerecommended for all apps;
others are recommended for specific business types or verticals. You should send
suggested events along with their prescribed parameters, to ensure maximum
available detail in your reports and to benefit from future features and
integrations as they become available. This section demonstrates logging a
pre-defined event, for more information on logging events, seeLog events.
The following code logs aSELECT_CONTENTevent when
a user clicks on a specific element in your app.
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 ofadbcommands:
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]