在BigQuery中使用事件名称和事件参数创建渠道(使用Firebase Analytics中的数据)

时间:2019-04-09 09:51:52

标签: google-bigquery firebase-analytics

在first_open事件之后,我有一个前20个事件的程序,但它仅返回event_name,这是一个问题,因为其中大多数是screen_view事件,其中实际屏幕名称是事件参数。有什么方法可以获取某些漏斗步骤的事件名称,以及获取screen_view事件的特定事件参数(称为firebase_screen)?

这是到目前为止的查询:

SELECT 
  SUM(user_first_open) as first_open_events_count, SUM(user_uninstall) as uninstall_events_count, COUNT(*) as sequence_count,
  event0, event1, event2, event3, event4, event5, event6, event7, event8, event9, 
  event10, event11, event12, event13, event14, event15, event16, event17, event18, event19
FROM 
  (
  SELECT 
    event_timestamp, user_pseudo_id,
    MIN(event_timestamp) OVER (PARTITION BY user_pseudo_id) as first_user_event_timestamp,
    MAX(CASE WHEN event_name = 'app_remove' THEN 1 ELSE 0 END) OVER (PARTITION BY user_pseudo_id) as user_uninstall,
    MAX(CASE WHEN event_name = 'first_open' THEN 1 ELSE 0 END) OVER (PARTITION BY user_pseudo_id) as user_first_open,
    event_name as event0,
    LEAD(event_name, 1) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event1,
    LEAD(event_name, 2) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event2,
    LEAD(event_name, 3) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event3,
    LEAD(event_name, 4) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event4,
    LEAD(event_name, 5) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event5,
    LEAD(event_name, 6) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event6,
    LEAD(event_name, 7) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event7,
    LEAD(event_name, 8) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event8,
    LEAD(event_name, 9) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event9,
    LEAD(event_name, 10) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event10,
    LEAD(event_name, 11) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event11,
    LEAD(event_name, 12) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event12,
    LEAD(event_name, 13) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event13,
    LEAD(event_name, 14) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event14,
    LEAD(event_name, 15) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event15,
    LEAD(event_name, 16) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event16,
    LEAD(event_name, 17) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event17,
    LEAD(event_name, 18) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event18,
    LEAD(event_name, 19) OVER (PARTITION BY user_pseudo_id ORDER BY event_timestamp) as event19
  FROM `data_set.events_*`
  WHERE
    event_name not in ('user_engagement', 'firebase_campaign', 'session_start')
  ORDER BY user_pseudo_id, event_timestamp
  )
WHERE 
  event_timestamp = first_user_event_timestamp
AND
  event0 = 'first_open'
GROUP BY 
  event0, event1, event2, event3, event4, event5, event6, event7, event8, event9, 
  event10, event11, event12, event13, event14, event15, event16, event17, event18, event19
ORDER BY sequence_count DESC

0 个答案:

没有答案