带参数的Firebase封闭渠道

时间:2018-11-30 15:16:48

标签: firebase google-bigquery firebase-analytics

我在Internet上看到了各种Firebase封闭漏斗examples,但它们都不是参数级的。

问题:

  • 我想基于Firebase事件参数值创建一个封闭的用户渠道。
  • 更具体地说,我想基于以下3个渠道步骤创建一个封闭的用户渠道:
    • first_open(用户首次打开应用)
    • Tutorial_LessonStarted,带有参数键LessonNumber和参数值1
    • Tutorial_LessonStarted,带有参数键LessonNumber和参数值2

(更新)我将原始的测试查询移至答案部分。

1 个答案:

答案 0 :(得分:0)

SELECT
    e0.event_date,
    COUNT(DISTINCT e0.user_pseudo_id) AS step1_firstOpeners,
    COUNT(DISTINCT e1_user) AS step2_lesson1Started,
    COUNT(DISTINCT e2_user) AS step3_lesson2Started
FROM `projectID.analytics_XXXX.events_*` AS e0
LEFT JOIN (SELECT
                event_name AS e1_eventname,
                e.user_pseudo_id AS e1_user,
                event_timestamp AS e1_ts
           FROM `projectID.analytics_XXXX.events_*` AS e, UNNEST(e.event_params) as eventparams
           WHERE platform = "ANDROID"
                AND event_name = "Tutorial_LessonStarted"
                AND eventparams.key = "LessonNumber"
                AND eventparams.value.string_value  = "1")
    ON e0.user_pseudo_id = e1_user AND e0.event_timestamp < e1_ts AND e1_eventname = "Tutorial_LessonStarted"
LEFT JOIN (SELECT 
                event_name AS e2_eventname,
                e.user_pseudo_id AS e2_user, 
                event_timestamp AS e2_ts
           FROM `projectID.analytics_XXXX.events_*` AS e, UNNEST(e.event_params) as eventparams
           WHERE platform = "ANDROID"
                AND event_name = "Tutorial_LessonStarted" 
                AND eventparams.key = "LessonNumber"
                AND eventparams.value.string_value  = "2")
    ON e1_user = e2_user AND e2_ts > e1_ts AND e2_eventname = "Tutorial_LessonStarted" 

WHERE 
    e0.event_name = 'first_open' 
    AND user_first_touch_timestamp >= 1541808000000000 AND user_first_touch_timestamp < 1541894400000000 -- 10 November 2018
    AND _TABLE_SUFFIX = '20181110'
AND platform = "ANDROID"
GROUP BY 1
ORDER BY 1 DESC