I recently came across this post to calculate MAU in BigQuery (Firebase Analytics data). I worked on this request to answer DAU, WAU and MAU for my project, but I saw some slight discrepancies in the calculations of MAU and WAU. The goal is to compute active user metrics that I can compare with the Firebase Dashboard here .
1) MAU calculation
SELECT
FORMAT_TIMESTAMP(
'%Y-%m',
TIMESTAMP_MICROS(user_dim.first_open_timestamp_micros)) AS year_and_month,
COUNT(DISTINCT user_dim.app_info.app_instance_id) AS monthly_visitors
FROM `<<project-id>>.app_events_*`
WHERE (_TABLE_SUFFIX BETWEEN '20170101' AND '20170731')
AND user_dim.first_open_timestamp_micros BETWEEN 1483228800000000 AND 1501545599000000
GROUP BY year_and_month
ORDER BY year_and_month DESC;
Questions:
2) WAU
SELECT
FORMAT_TIMESTAMP(
'%Y-%W',
TIMESTAMP_MICROS(user_dim.first_open_timestamp_micros)) AS year_and_week,
COUNT(DISTINCT user_dim.app_info.app_instance_id) AS weekly_visitors
FROM `<<project-id>>.app_events_*`
WHERE (_TABLE_SUFFIX BETWEEN '20170306' AND '20170917')
AND user_dim.first_open_timestamp_micros BETWEEN 1488758400000000 AND 1505692799000000
GROUP BY year_and_week
ORDER BY year_and_week DESC;
- 50% , Firebase Console. , 10% - , 50% .
- "% Y-% W" , "% Y-% w" (, "% Y-% m" MAU), ?
3) DAU
, . , first_open firebase .
SELECT
FORMAT_TIMESTAMP(
'%D',
TIMESTAMP_MICROS(user_dim.first_open_timestamp_micros)) AS year_and_day,
COUNT(DISTINCT user_dim.app_info.app_instance_id) AS day_visitors
FROM `<<project-id>>.app_events_*`
WHERE (_TABLE_SUFFIX = '20170917')
AND user_dim.first_open_timestamp_micros BETWEEN 1505606400000000 AND 1505692799000000
GROUP BY year_and_day
ORDER BY year_and_day;
: