会话持续时间 - 谷歌分析和 Firebase 报告之间的巨大差异
Posted
技术标签:
【中文标题】会话持续时间 - 谷歌分析和 Firebase 报告之间的巨大差异【英文标题】:Session Duration - large discrepancy between google analytics and firebase reporting 【发布时间】:2019-11-02 00:59:41 【问题描述】:我们目前正在从谷歌分析(移动数据)迁移到 Firebase。
firebase 中的数据正在流式传输到 BigData,我们使用以下查询来计算会话持续时间。
当我针对这些会话生成报告时,通过 Firebase 报告的平均会话持续时间大约是 Google 分析报告的平均会话持续时间的 4 倍。
我在各种设备(android、ios)上都有同样的问题,并且同时向谷歌分析和 firebase 发送相同的自定义事件
使用 session_start 事件或 unnest user_properties 并直接使用 ga_session_number 来代替给出相同的结果。
with timeline as
(
select
geo.city as geo_city
,device.operating_system as device_category
, user_pseudo_id
, event_name
, event_timestamp
, lag(event_timestamp, 1) over (partition by user_pseudo_id order by event_timestamp) as prev_event_timestamp
from
`projid.analytics_xxx.events_*`
)
, session_timeline as
(
select
event_name
, geo_city
, device_category
, user_pseudo_id
, event_timestamp
, prev_event_timestamp
, case
when
event_timestamp - prev_event_timestamp >= (30*60*1000*1000)
or
prev_event_timestamp is null
then 1
else 0
end as is_new_session_flag
from
timeline
)
, marked_sessions as
(
select
device_category
, geo_city
, user_pseudo_id
, event_timestamp
, prev_event_timestamp
, sum(is_new_session_flag) over (partition by user_pseudo_id order by event_timestamp) AS user_session_id
, min(prev_event_timestamp) over (partition by user_pseudo_id order by event_timestamp) AS first_prev_event_timestamp
from session_timeline
)
, measured_sessions as
(
select
device_category
, geo_city
, user_pseudo_id
, user_session_id
, FORMAT_TIMESTAMP("%F", TIMESTAMP_MICROS(first_prev_event_timestamp)) as first_time_date
, FORMAT_TIMESTAMP("%F", TIMESTAMP_MICROS(min(event_timestamp))) as date
, round((max(event_timestamp) - min(event_timestamp))/ (1000 * 1000), 2) as session_duration_seconds
, round((max(event_timestamp) - min(event_timestamp))/ (1000 * 1000 * 60), 2) as session_duration_minutes
, round((max(event_timestamp) - min(event_timestamp))/ (1000 * 1000 * 60 * 60), 2) as session_duration_hours
from
marked_sessions
group by
user_pseudo_id
, user_session_id
, device_category
, geo_city
, first_prev_event_timestamp
having
-- let's count only sessions longer than 10 seconds
session_duration_seconds >= 10
)
select
*
from
measured_sessions
order by date desc, user_pseudo_id desc, user_session_id desc
不仅平均会话时长存在显着差异,甚至会话数也相差甚远。
【问题讨论】:
【参考方案1】:您的结果是否经过抽样?通常reporting discrepancies in Google Analytics 是由于采样。尝试导入按较少维度分组的数据或使用较短的时间段。
【讨论】:
以上是关于会话持续时间 - 谷歌分析和 Firebase 报告之间的巨大差异的主要内容,如果未能解决你的问题,请参考以下文章
当用户离线时,Firebase 身份验证会话会持续多长时间?
Firebase Analytics 如何处理后台活动的会话持续时间(mp3 播放器)