Bigquery中新安装的购买者群组的Firebase事件

时间:2018-08-01 13:22:08

标签: firebase google-bigquery firebase-analytics

鉴于android用户的安装日期,对于要在安装后定义的时间段内至少购买过一次的用户,我希望从第0天到dayX的200多个Firebase事件获得用户计数。此问题的前半部分先前已在此question中解决。我认为,共享一个添加的“购买者”队列查询以供其他人重复使用会很有帮助。

我的第一次尝试(失败):

-- STANDARD SQL
-- NEW BIGQUERY EXPORT SCHEMA
SELECT
  a.event_name AS event_name,
  a._TABLE_SUFFIX as day,
  COUNT(1) as users
FROM `xxxx.analytics_xxxx.events_*` as c
    RIGHT JOIN (SELECT user_pseudo_id, event_date, event_timestamp, event_name
                FROM `xxxx.analytics_xxxx.events_*`
                WHERE user_first_touch_timestamp BETWEEN 1530453600000000 AND 1530468000000000
                AND _TABLE_SUFFIX BETWEEN '20180630' AND '20180707'
                AND platform = "ANDROID"
                AND (event_name = 'in_app_purchase' OR event_name = 'ecommerce_purchase')
                ) as a
    ON a.user_pseudo_id = c.user_pseudo_id 
WHERE _TABLE_SUFFIX BETWEEN '20180630' AND '20180707'
GROUP BY event_name, day;

1 个答案:

答案 0 :(得分:0)

答案:

-- STANDARD SQL
-- NEW BIGQUERY EXPORT SCHEMA
SELECT    
  event_name AS event_name,
  _TABLE_SUFFIX as day,
  COUNT(1) as users
FROM `xxxx.analytics_xxxx.events_*`
    WHERE _TABLE_SUFFIX BETWEEN '20180630' AND '20180707'
    AND user_pseudo_id IN (SELECT user_pseudo_id
                           FROM `xxxx.analytics_xxxx.events_*`
                           WHERE _TABLE_SUFFIX BETWEEN '20180630' AND '20180707'
                           AND user_first_touch_timestamp BETWEEN 1530453600000000 AND 1530468000000000
                           AND (event_name = 'in_app_purchase' OR event_name = 'ecommerce_purchase')
                           AND platform = "ANDROID")
GROUP BY event_name, day;

PS:始终欢迎您优化此脚本的建议:)