我正在使用导出到BigQuery的FirebaseAnalytics数据来分析我们的应用程序。
为了检查用户转换,我编写如下的sql。

with users_with_screen_view_and_session_id as (
  SELECT
    user_id,
    user_pseudo_id,
    event_date,
    event_timestamp,
    event_name,
    platform,
    case
      when event.key = 'firebase_screen'
        and event.value.string_value is not null then event.value.string_value
      when event.key = 'firebase_screen'
        and event.value.int_value is not null then cast(event.value.int_value as string)
      else null
    end as firebase_screen,
    case
      when event.key = 'ga_session_id'
        and event.value.string_value is not null then event.value.string_value
      when event.key = 'ga_session_id'
        and event.value.int_value is not null then cast(event.value.int_value as string)
      else null
    end as session_id
  FROM
    `{my_project}.analytics_{my_id}.events_*`  as main
    ,unnest(event_params) as event
    WHERE _TABLE_SUFFIX BETWEEN '20191001' AND '20191001'
    and event_name = 'screen_view'
),
users_with_screen_view_agg_firebase_screen as (
  select
    user_id,
    user_pseudo_id,
    event_date,
    event_name,
    platform,
    event_timestamp,
    max(firebase_screen) as firebase_screen,
    max(session_id) as session_id
  from
    users_with_screen_view_and_session_id
  group by
    user_id,
    user_pseudo_id,
    event_date,
    event_name,
    platform,
    event_timestamp
)
select
  *
from
  users_with_screen_view_agg_firebase_screen
;
我以为每个事件都有ga_session_id,但是在此查询结果中,有些行的ga_session_id为null。
在什么情况下ga_session_id值会变为null?
查询结果的图像在这里。
enter image description here

最佳答案

可能缺少 session 的主要原因是由于SDK的版本。在2018年底,firebase SDK上有一个change,旨在删除缺失的ga_sessions_id,因此请检查您的SDK版本是否至少为16.5.0或更高。
如果这似乎不是您的问题,建议您直接向Firebase支持here进行检查,以便他们了解这种情况。

09-05 20:16