12.3 Analytics

Google Analytics is a free app measurement solution that provides insight on app usage and user engagement. Analytics reports help you understand clearly how your users behave, which enables you to make informed decisions regarding app marketing and performance optimizations. Maybe you want to know how often users are clicking a certain button on your app or how much they are using a new feature you just released. Analytics can help with that and it's super easy to set up! Think of it as having a low skill floor but a moderate skill ceiling.

Setting up Analytics

Make sure your Firebase project is set up, the steps of which are covered in the first section 11.1!
Declare the dependency for the Analytics Android library in your module (app-level) Gradle file:
implementation 'com.google.firebase:firebase-analytics-ktx'
When accessing most Analytics services, you need the appropriate FirebaseAnalytics object.
private lateinit var firebaseAnalytics: FirebaseAnalytics
You can then initialize it in the onCreate method of your activity:
firebaseAnalytics = Firebase.analytics

Using Analytics

The core of analytics is the logEvent() function, which allows you specify the event and any additional parameters you may want to store with that event (i.e. maybe the specific article someone clicks on if your app is a news aggregator for a college campus such as Cornell). Google also provides some predefined events/parameters that you can explore also (and I recommend taking a look at first)! Here's an example:
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) {
param(FirebaseAnalytics.Param.ITEM_ID, SOME_ID)
param(FirebaseAnalytics.Param.ITEM_NAME, SOME_NAME)
param(FirebaseAnalytics.Param.CONTENT_TYPE, "image")
}
The code above logs SELECT_CONTENT event when a user clicks on a specific element in your app.
Google has a lot of baseline events that can be tailored according to your needs. They cover vertical markets and business types like Retail/E-commerce, Games, etc. Check some out here!

Seeing data

Example Google Analytics dashboard
Firebase Analytics dashboard
Right off the bat, the dashboard tells you a lot of things:
  1. 1.
    You can see what the demographic information of your users are,
  2. 2.
    How regularly they use your app,
  3. 3.
    How much time they spend there, and
  4. 4.
    How much they have spent on your app.
The data captured on your app can be viewed from the dashboard in the Firebase console from here on. You’ll see predefined events that have automatically been captured by the SDK, such as active users, demographics and app engagement.
If you have both an iOS and Android version you will see the data for both of them on the dashboard. You can look at the data for just one version by clicking on ‘filters’. Filters also allow you to analyze the data for different audiences you have set up.
By default, the dashboard will show you the last 30 days of data, but you can change this by using the date picker control.
There’s a lot of different data and information on the dashboard to help you understand your app. It starts with active users i.e. how many users are in your app on a daily, weekly and monthly basis. As well as how many users are active in the last 30 minutes.
It shows user engagement, such as how much time people spend within your app. It also shows conversion metrics. If you have in-app purchasing you see this data along with information on Admob if you’re generating revenue.
There’s a section on the stability of your app. It shows the percentage of crash-free users.
Another card on the dashboard shows the latest release of your app along with the status of that release. The status allows you to click into it to investigate any issues.

Audiences

Once the data within your app is captured via these events you've logged, you’re able to create audiences, and group users based on certain attributes like ‘purchasing users’.
Audiences are particularly useful when used in conjunction with other Firebase features. For example, you can send custom notifications using Firebase Notifications. Notifications can even be used to target users with Google’s ad platform. Maybe you want to target users prone to cart abandonment and send them a notification to egg them on to complete a purchase.
The events data captures the overall performance of your app, but ‘user properties’ and ‘audiences’ drills down further into specific behavior. By using user properties and audiences you can segment the data captured for better insights into how your app is being used.
When you click the ‘user properties’ table you can register a property, such as the profession of your users. You then use the API to call that specific information.
You can create audiences of users who meet certain criteria and user property criteria. Once you set up the audience it will start to accumulate users who meet these criteria. You can then target these audiences with particular campaigns.

Conclusion

And this is just the tip of the iceberg of what Google Analytics for Firebase can do for you and a good baseline as to where you can go next. I truly implore you to look into the powerhouse that is Google Analytics, as it could take your app to the next level in terms of audience and reach!

Things to explore next

  • Google Ads (using Firebase data in combination to help with targeting ads) & Audiences ​
  • BigQuery
  • Firebase Remote Config