Reputation: 159
i have use FireBase analytics process that is given in google but after that not track any data in firebase analytics. how to integrate firebase analytics in android ?
Upvotes: 3
Views: 3918
Reputation: 2534
Follow the below steps to implement Google Firebase Analytics to your Android App:
Java : implementation 'com.google.firebase:firebase-analytics:17.5.0'
Kotlin : implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'
Java : private FirebaseAnalytics mFirebaseAnalytics;
Kotlin : private lateinit var firebaseAnalytics: FirebaseAnalytics
Initialize it in the onCreate() method:
Java :
// Obtain the FirebaseAnalytics instance... mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Kotlin :
// Obtain the FirebaseAnalytics instance.. firebaseAnalytics= Firebase.analytics
You have successfully Integrated the Firebase Analytics in your App.
Now for Logging Events Follow the below procedure :
The following code logs a SELECT_CONTENT event when a user clicks on a specific element in your app.
Java :
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);
Kotlin :
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) {
param(FirebaseAnalytics.Param.ITEM_ID, id)
param(FirebaseAnalytics.Param.ITEM_NAME, name)
param(FirebaseAnalytics.Param.CONTENT_TYPE, "image")
}
Upvotes: 1
Reputation: 870
If you followed the steps here then you'll have to wait for 24 hours to see the data in the console. It updates periodically.
Upvotes: 3