Firebase Analytics

Firebase Analytics is a measurement solution that provides information free apps on using the app and user interaction with the event logs within the app. In addition, we can define custom audiences in the Firebase console according data we want to target.


Firebase collects two main types of information:

  • Events: What is happening within our application as system events, user actions or errors.
  • User Properties: This information is used to segment the user who is using the application as language or geolocation.

To use Firebase Analytics in our app we have to add the ‘firebase-core’ library which already included the analytical module. To integrate our application with Firebase we can follow the previous post.

In the activity (or activities) where we will use the statistics must initialize:

private FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(context);

Once we have initialized the Firebase instance can already use it to send the statistics we want to register. We can record both custom and predefined events. Predefined events are very common to several applications. We can see a list of predefined events on the link. We have to record only important events in our app.

For this, we must use the method ‘LogEvent’ that accepts a (predefined or custom) event and an object of type Bundle containing more statistical parameters.

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);

Another example:

Bundle params = new Bundle();
params.putString("user_id", id);
params.putString("user_name", name);
firebaseAnalytics.logEvent("user", params);

Finally, we can include data concerning users, for example tastes or trends.

mFirebaseAnalytics.setUserProperty("hobby", user_hobby);

Analytics can analyze easily user interactions in our app and help us to detect the most important sections and less-used parts of our app.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s