Android Firebase – Integrating Analytics

Another interesting feature that firebase offers is the Firebase Analytics. Free, simple and unlimited. Sounds like a scam? Luckily google is not joking. Analytics integrates across Firebase features and provides you with unlimited reporting for up to 500 distinct events that you can define using the Firebase SDK.

Firebase Analytics reports help you understand clearly how your users behave, which enables you to make informed decisions regarding app marketing and performance optimizations. Firebase Analytics helps you understand how people use your app.

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

Firebase Analytics also integrates with a number of other Firebase features. For example, it automatically logs events that correspond to your Firebase Notifications and provides reporting on the impact of each campaign.
Here are the events and user properties that Firebase Analytics offers without adding any additional code to you project.

Automatically Collected Events

Automatically collected events are triggered by basic interactions with your app. As long as you use the Firebase SDK, you don’t need to write any additional code to collect these events. Below are list of event collected automatically.

Event name

Triggered…

first_open

when a user opens the app for the first time.

This event is not triggered when a user downloads the app onto a device, but instead when he or she first uses it. To see raw download numbers, look in Google Play Developer Console or in iTunesConnect.

in_app_purchase

when a user completes an in-app purchase that is processed by the App Store on iTunes or Google Play. The product ID, product name, currency, and quantity are passed as parameters.

This event is triggered only by versions of your app that include the Firebase SDK. Also, subscription revenue, paid app-purchase revenue, and refunds are not automatically tracked, and so your reported revenue may differ from the values you see in the Google Play Developer Console.

user_engagement

periodically, while the app is in the foreground.

session_start

when a user engages the app for more than the minimum session duration.

app_update

when the app is updated to a new version and launched again. The previous app version id is passed as a parameter.

app_update varies from Daily upgrades by device, which is reported by Google Play Developer Console whether or not the app is launched again after update.

app_remove

when an application package is removed or “uninstalled” from an Android device.

This event is different from the Daily uninstalls by device and Daily uninstalls by user metrics, which are both reported by Google Play Developer Console. The app_remove event counts the removal of application packages, regardless of the installation source, and the count changes depending on the date range you are using for the report. The Daily uninstalls by device and Daily uninstalls by user metrics count the removal of application packages only when they were installed from Google Play, and are reported on a daily basis.

os_update

when the device operating system is updated to a new version. The previous operating system version id is passed as a parameter.

app_clear_data

when the user resets/clears the app data, removing all settings and sign-in data.

app_exception

when the app crashes or throws an exception.

notification_foreground

when a notification sent by Firebase Cloud Messaging is received while the app is in the foreground.

notification_receive

when a notification sent by Firebase Cloud Messaging is received by a device when the app is in the background. Android apps only.

notification_open

when a user opens a notification sent by Firebase Cloud Messaging.

notification_dismiss

when a user dismisses a notification sent by Firebase Cloud Messaging. Android apps only.

dynamic_link_first_open

when a user opens the app for the first time via a dynamic link. iOS app only.

dynamic_link_app_open

when a user opens the app via a dynamic link. iOS apps only.

dynamic_link_app_update

when the app is updated to a new version via a dynamic link. iOS apps only.

Integrating Firebase Analytics

Now we’ll create a simple app which collects user chosen food on firebase analytics dashboard. All we do is collect user id along with the food he is choosing.

1. First thing you need to do is go to https://firebase.google.com/ and make an account to gain access to their console. After you gain access to the console you can start by creating your first project.

2. Give the package name of your project (mine is info.androidhive.firebase) in which you are going to integrate the Firebase. Here the google-services.json file will be downloaded when you press add app button.

3. Create a new project in Android Studio from File ⇒ New Project. While filling the project details, use the same package name which you gave in firebase console. In my case I am using same info.androidhive.firebase.

4. Open AndroidManifest.xml and add the INTERNET permission as we need to make network calls.

<uses-permission android:name="android.permission.INTERNET" />

5. Paste the google-services.json file to your project’s app folder. This step is very important as your project won’t build without this file.

6. Now open the build.gradle located in project’s home directory and add firebase dependency.

Hi there! I am Founder at androidhive and programming enthusiast. My skills includes Android, iOS, PHP, Ruby on Rails and lot more. If you have any idea that you would want me to develop? Let’s talk: ravi@androidhive.info

Normally we implement these kind of operations on server side as we can’t have lot of audio stored in the app. What you can do is send the audio from android to server, server performs the validation / match and returns the response.

surya ramiah

ravi sir u should make video tutorial

avinash

Where can i see the custom bunble values in firebase console

Shafayat Mamun

Can you make a tutorial about android mvp(model-view-presenter) architecture?

Dia Bader

Nice tutorial and we are waiting a wonderful article form you 🙂 again thank you so much

Vinu Chacko

Nice tutorial Sir.
Am a beginner in fire base. So I have a big doubt, Can we use server side code for sending push notification to android apps using fire base? Is it possible? Am developing an android app that need push notification, So which is the best method GCM or FCM. .? Hope my question is clear. Please give me an answer.
Thank you

Vipin Negi

Yeah you can use server side code for sending push notification.
Unfortunately GCM has been discontinued and cannot be used further on any new applications. FCM is better than GCM and more reliable IMHO. So go ahead with FCM.

With FCM, you can send two types of messages to clients:
1. Notification messages, sometimes thought of as “display messages.”
2. Data messages, which are handled by the client app.

make sure you used the ‘Data Messages’ to send notification configured on server.

ali masri

you can Download : “Master Android” & Learn Firebase From Zero To Hero

titi

lol HARDCORE Android MMMMMMMMMDR !!!!!

Faisal Mohammed

Ravi, great job. Insightful.
Any plans to plot a sample of user/behavior flow using Firebase analytics?
Any idea how to capture and upload to Firebase? Thanks.

Ashutosh Tripathi

Hi, Ravi..Great Tutorial..
Can you please give a tutorial on how to integrate paytm…it would be great Thanks

Hi Ravi.. Great Tutorials you’ve got. Can you please do a tutorial on Android Chat app/sending push notifications using Smack Library (XMPP). Thanks

ashwani Janu

Yeah that one I would love too.. Thanks @ravi8x:disqus for sharing these tuts, always helpful.

‫إليود نجوغونا‬‎

Thanks for the Tutorial but my app did not run because the Google Play Services in my Emulator is out of date..I have tried everything thats has been said in almost all chats and tutorial but i haven’t found any solution to that.

I implement firebase analytics, so it working fine and generate log event in debug console but, this log event can’t upload on firebase console. i also waiting 3 to 4 days but no any recode on firebase console, below is my debug log,