Ram*_*n M 2 google-bigquery firebase-analytics
平均 之前在 Firebase 分析仪表板中可用的会话持续时间指标。但现在,它在 Firebase 分析仪表板中不可用。现在,我们只看到“每位用户的参与度”。是每个用户和平均的参与度。会话时长 两者相同吗?如何提取平均值 Fiebase 分析的会话持续时间?如何在 Bigquery 中查询以提取 Avg. Firebase 的会话持续时间指标。 在此处输入图片说明
每个用户的参与度与平均互动度不同。会话持续时间。每个用户的参与度是指用户在一天内在应用中花费的所有时间,而不是在会话中。
你可以找到平均。Firebase Analytics 中最新版本下的会话持续时间。
这是用于计算 avg 的查询。BigQuery 中的会话长度:
with timeline as
(
select
user_pseudo_id
, event_timestamp
, lag(event_timestamp, 1) over (partition by user_pseudo_id order by event_timestamp) as prev_event_timestamp
from
`YYYYY.analytics_XXXXX.events_*`
where
-- at first - a sliding period - how many days in the past we are looking into:
_table_suffix
between format_date("%Y%m%d", date_sub(current_date, interval 10 day))
and format_date("%Y%m%d", date_sub(current_date, interval 1 day))
)
, session_timeline as
(
select
user_pseudo_id
, event_timestamp
, case
when
-- half a hour period - a threshold for a new 'session'
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
user_pseudo_id
, event_timestamp
, sum(is_new_session_flag) over (partition by user_pseudo_id order by event_timestamp) AS user_session_id
from session_timeline
)
, measured_sessions as
(
select
user_pseudo_id
, user_session_id
-- session duration in seconds with 2 digits after the point
, round((max(event_timestamp) - min(event_timestamp))/ (1000 * 1000), 2) as session_duration
from
marked_sessions
group by
user_pseudo_id
, user_session_id
having
-- let's count only sessions longer than 10 seconds
session_duration >= 10
)
select
count(1) as number_of_sessions
, round(avg(session_duration), 2) as average_session_duration_in_sec
from
measured_sessionsRun Code Online (Sandbox Code Playgroud)
有关如何获取 event_date 和 app_info.id 的其他问题,请参阅以下查询:
with timeline as
(
select
event_date,app_info.id,user_pseudo_id
, event_timestamp
, lag(event_timestamp, 1) over (partition by user_pseudo_id order by event_timestamp) as prev_event_timestamp
from
`<table>_*`
where
-- at first - a sliding period - how many days in the past we are looking into:
_table_suffix
between format_date("%Y%m%d", date_sub(current_date, interval 10 day))
and format_date("%Y%m%d", date_sub(current_date, interval 1 day))
)
, session_timeline as
(
select
event_date,id,
user_pseudo_id
, event_timestamp
, case
when
-- half a hour period - a threshold for a new 'session'
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
event_date,id, user_pseudo_id
, event_timestamp
, sum(is_new_session_flag) over (partition by user_pseudo_id order by event_timestamp) AS user_session_id
from session_timeline
)
, measured_sessions as
(
select
event_date,id, user_pseudo_id
, user_session_id
-- session duration in seconds with 2 digits after the point
, round((max(event_timestamp) - min(event_timestamp))/ (1000 * 1000), 2) as session_duration
from
marked_sessions
group by
event_date, id, user_pseudo_id
, user_session_id
having
-- let's count only sessions longer than 10 seconds
session_duration >= 10
)
select
event_date, id, count(1) as number_of_sessions
, round(avg(session_duration), 2) as average_session_duration_in_sec
from
measured_sessions
group by event_date, idRun Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3339 次 |
| 最近记录: |