https://www.youtube.com/watch?v=wCb5O_U6yVg&list=PLpn2Pzb485yhVWjcs_sfYIs1v-ddmcH2D&index=15
SELECT
date,
min_date,
users,
diff,
FIRST_VALUE(users) OVER(PARTITION BY min_date ORDER BY diff) AS first_month_users,
users / FIRST_VALUE(users) OVER(PARTITION BY min_date ORDER BY diff) AS retained
FROM (
SELECT
FORMAT_DATE("%Y - %W",PARSE_DATE("%Y%m%d",
date)) AS date,
FORMAT_DATE("%Y - %W",PARSE_DATE("%Y%m%d",
min_date)) AS min_date,
DATE_DIFF(PARSE_DATE("%Y%m%d",
date),PARSE_DATE("%Y%m%d",
min_date),WEEK(MONDAY)) AS diff,
COUNT(DISTINCT(fullVisitorId)) AS users
FROM (
SELECT
fullVisitorId,
date,
MIN(date) OVER(PARTITION BY fullVisitorId) AS min_date
FROM
`bigquery-public-data.google_analytics_sample.ga_sessions_2016*`,
UNNEST (hits) AS hits
WHERE hits.transaction.transactionId IS NOT NULL
GROUP BY
1,
2)
GROUP BY
1,
2,
3)
GROUP BY
1,
2,
3,
4
https://datastudio.google.com/embed/reporting/d58b1a82-a763-47e3-8890-6927f0d9f055/page/bDTuB
https://www.youtube.com/watch?v=0kxYYi0U6G0&list=PLpn2Pzb485yhVWjcs_sfYIs1v-ddmcH2D&index=16
Создать визуализацию с помесячным количеством пользователей по всей таблице ga_sessions. Разделить пользователей на 3 (опционально 4) типа:
Пример похожей визуализации здесь: https://medium.com/swlh/diligence-at-social-capital-part-1-accounting-for-user-growth-4a8a449fddfc#.qxpy0xpda
(мы добавляем понятие retained и не считаем соотношения)