Updated 14 December 2016
Firebase Analytics is a free app measurement solution that provides insight on app usage and user engagement.
You can log the event firebase sdk default event and also custom event.
1) CAPTURE LOG EVENTS
The Firebase SDK automatically captures a number of events and user properties and also allows you to define your own custom events to measure the things that uniquely matter to your business. Once the data is captured, it’s available in a dashboard through the Firebase console.
2) DISPLAY ON FIREBASE CONSOLE/DASHBOARD
This dashboard provides detailed insights about your data — from summary data such as active users and demographics, to more detailed data such as identifying your most purchased items.
1) Add Analytics to your app
Add the dependency for Firebase Analytics to your app-level build.gradle
file:
1 <span class="pln">compile </span><span class="str">'com.google.firebase:firebase-core:9.8.0'</span>
2) LOG events
First of all, we have created to separate class for logging Analytics event:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
public class FirebaseAnalyticsImpl { private static FirebaseAnalytics mFirebaseAnalytics; public FirebaseAnalyticsImpl(Context context) { // Obtain the FirebaseAnalytics instance. mFirebaseAnalytics = FirebaseAnalytics.getInstance(context); } public static void logSignUpEvent(Context context, String customerId, String customerName) { if (mFirebaseAnalytics == null) { // get instance of firebase analytics if it is not instantiated mFirebaseAnalytics = FirebaseAnalytics.getInstance(context); } // Create a bundle data used to log the event Bundle bundle = new Bundle(); // Passing values for the default keys ITEM_ID and ITEM_NAME bundle.putString(FirebaseAnalytics.Param.ITEM_ID, customerId); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, customerName); // Final logging of event using firebase analytics instance mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SIGN_UP, bundle); } } |
We can call the static method to perform logging events.
1 |
FirebaseAnalyticsImpl.logLoginEvent(this, customerId, customerName); |
Finally you can check the log event (However you have to wait for a day for first new log event to start displaying data) in the Analytics events dashboard.
That’s all folks!!
Stay Updated !!
REFERENCES:
https://github.com/firebase/quickstart-android/tree/master/analytics
https://firebase.google.com/docs/analytics/
https://firebase.google.com/docs/analytics/android/start/
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.