Retention and App Remove Analysis using Google Analytics for Firebase, BigQuery and Data Studio
By: Ed Adityawarman
Tags: Bigquery, Data Studio, Firebase, Retention, Analytics

Retention and App Remove Analysis using Google Analytics for Firebase, BigQuery and Data Studio

There are only x% of users who are active on day 7, but is it true that the rest have left us?

It seems that we no longer need to debate whether it is essential to carry out retention analysis when developing an application. Product owners can be happy and proud to see the number of installs or daily active users go up — it can be useful as a tool to make beautiful reports or maybe as sales material. But retention rates will be more exciting and important to pay attention to because retention rates are better at communicating the actual state of the app and its user base.

Retention Analysis

Google Analytics for Firebase has helped us in analysing retention. Todd Kerpelman has also made a post on how to do retention analysis through Firebase and BigQuery. In this post, I will try to add a few things that might complement what already exists.

There are at least three different ways to visualise retention.

First, is to visualise it as a curve — commonly known as the retention curve — with the number of days after first open as the x-axis and the retention rate as the y-axis.

Second, display it as a heatmap table, with dates as rows, days as columns, and retention rate as the values.

We can get both of them through the retention report in Firebase.

The third way is to plot each N-day retention as lines with the date as the x-axis. Note that in this third method, we don’t need to display all N-days, but enough with 1-day, 7-day, 28-day and 30-day retention rates, or whatever day we think is important.

Because the third way of visualisation is not available by default in Firebase, we can build it by doing a custom query in BigQuery and then visualising it through Data Studio.

Let’s start by querying the data for the retention rate. For convenience, let’s use firebase public data. There are several ways to perform query for retention analysis, and this is just one of them:

Retention Analysis Query

Let me walk you through the above query, and explain a couple of interesting aspects.

first_open sub-query: We must retrieve data about who are the users who opened the application for the first time in the period that we have specified. In this example, we are calculating daily retention. So, we need the date of the first_open event, and user_pseudo_id for user identification. active sub-query: We must retrieve data about who are active users in the period that we have specified. So, we also need the user_pseudo_id and the date they were active. Please note that here I am excluding the app_remove event (It maybe necessary to also exclude notification_dismiss, notification_foreground, notification_receive events). Hint: You can also use other events according to how your product defines active users. In most cases, session_start and screen_view will suffice. cohort_size sub-query: This block is used to calculate how many new users are joined in each cohort (in this example I am grouping users by date). Retrieve only active users who have the first_open date in the range we have defined. For that, we need to do a left join between the first_open and active sub-queries based on their user_pseudo_id . Then we calculate the difference in days between the active date and the first_open date. After that, count the number of active (retained) users grouped by date and their days difference. To get the retention rate value, we have to divide the number of retained users on each date and days by the number of new users that we can get by doing a left join with the cohort_size sub-query.

Note: I use the Jakarta timezone because I happen to live there for now.

If you want to calculate weekly or monthly retention, you can replace some of the query lines above in this way:

-- Change these lines (line 3 & line 10)

DATE(TIMESTAMP_MICROS(event_timestamp),"Asia/Jakarta") -- change to week

DATE_TRUNC(DATE(TIMESTAMP_MICROS(event_timestamp),"Asia/Jakarta"), WEEK) -- change to month

DATE_TRUNC(DATE(TIMESTAMP_MICROS(event_timestamp),"Asia/Jakarta"), MONTH)

Don’t forget to also change the DATE_DIFF function to get the weekly/monthly intervals between active and first open.

-- line 22

DATE_DIFF(active.active_dt, first_open.first_open_dt, DAY) -- change to week

DATE_DIFF(active.active_dt, first_open.first_open_dt, WEEK) -- change to month

DATE_DIFF(active.active_dt, first_open.first_open_dt, MONTH)

After getting the result, click Explore Data with Data Studio.

Data Studio Configuration

Voila! So this is how the third version of retention visualisation looks like.

N-day Retention Trends

Each visualisation has its use. The first visualisation will help us more easily understand how steep the curve is, and in how many days and at what percentage of retention begins to stabilise. The second visualisation is excellent at showing the cohort as a whole. The third visualisation is a bit like the second, but it should be better at helping us understand the daily trends and extract information more quickly.

App Remove Analysis

Apart from retention, Google Analytics for Firebase also equips us with an app_remove event which tells us if a user has removed our application from their Android device. We can also filter it according to various dimensions such as campaigns, versions, platforms, and others.

It would be interesting if we could use it to complement our retention analysis.

One day at work, the product manager asked me, as written in the subtitle above. “There are only x% of users active on day 7, but is it true that the rest have left us?”

It’s a challenging question. The answers can decide what action to take. Apart from making improvements and iterating, can we make re-engagement efforts, or do we lose our users and need to be aggressive in acquiring new users?

To answer that, we’re going to do a bit of analysis similar to retention, but instead of using an event indicating that the user is active, we’ll use the app_remove event.

App Remove Analysis Query

We retrieve the data on which user triggered the app_remove event and when it occurred. Since app_remove can only happen once per user, we need to calculate it cumulatively. Please take a look at the cmltv sub-query. This is different from retention, where a user can be active for more than one day or even multiple times.

You may see the GENERATE_ARRAY(0,30) function. I added it to replace the missing dates when the app_remove event did not occur in our dataset (which is a perfect thing, of course!). In real-world, maybe you can get rid of this function, considering that there are almost always users who remove the application every day.

Necessary: Please set the _TABLE_SUFFIX as needed for the analysis to reduce the number of bytes to be queried, improve performance, and reduce the query price.

Query result

Now that we get the result, let’s visualise it with Data Studio! Choose the cum_remove_rate field as the metrics. Change the default aggregation from SUM to AVG, and you should be able to get this — maybe beautiful, maybe sad — app remove curve.

So, we know that around 32% of users remove the app seven days after first open! If you have a 20% day seven retention rate, then you could improve it to a maximum of around 68%!

Conclusion

This brings me to the end of this post. So, we have learned together:

How to perform retention rate analysis and multiple ways to visualise it.

How to change the cohort from day to weekly or monthly retention using DATE_TRUNC() function.

How to use the GENERATE_ARRAY() function to fill in missing data.

How to utilize the app_remove event in Google Analytics for Firebase to complement our retention analysis.

event in Google Analytics for Firebase to complement our retention analysis. How to visualise query results using Data Studio.

Lastly, if we take another look at both results of the retention and the app remove queries, they both have fields that can be linked to each other. You can combine both queries in a single query and combine both curves in one visualisation. Or you can blend the results in Data Studio. The combination of retention and app remove analysis will lead us to a more precise solution to the question of retention and growth in the application we are developing.