问题:
我找到了这个example,它使我可以获取所有user_id,但是使用了非常过滤的方法。然后,我进行了自我加入,只是为这些高活跃用户的购买进行了补充(到目前为止没有成功)。也许有一种更简单的方法,但是我的想法是不仅要添加购买列,而且以后还要添加其他转化事件:session_start,user_login,download_video等。任何贡献都值得赞赏!
#STANDARD_SQL
SELECT
DISTINCT T.user_id,
T.event_params.key,
SUM(T.event_params.value.int_value),
COUNT(Z.event_name)
FROM `bigquery-table.analytics_xxxx.events_*` AS T, T.event_params
LEFT JOIN `bigquery-table.analytics_xxxx.events_*` AS Z, Z.event_params
ON T.user_pseudo_id = Z.user_pseudo_id
WHERE
T.event_name = 'user_engagement'
AND Z.event_name = 'in_app_purchase'
# User engagement in the last M = 10 days */
AND T.event_timestamp > UNIX_MICROS(TIMESTAMP_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY))
AND T.event_params.key = 'engagement_time_msec'
AND _TABLE_SUFFIX BETWEEN '20180716' AND '20240131'
AND platform = 'ANDROID'
GROUP BY 1,2
# Having engaged for more than N = 5 minutes
HAVING SUM(T.event_params.value.int_value) > 3 * 60 * 1000000