I need to create a "session level" table using big query. For this, I use the session_id, user_speudo_id and other metrics/dimensions. When I try to calculate the "average engagement time" of GA4, I use the following formula.
However, I get 19 minutes with BigQuery while GA4 shows an average engagement time of 30 minutes. Has anyone ever calculated this metric with BigQuery?
SELECT
DISTINCT ( SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,
max((select value.int_value from unnest(event_params) where key = 'engagement_time_msec')) as timeOnSite_ms
FROM tableXXXX
try this one
SELECT
distinct (SELECT value.int_value FROM UNNEST(event_params) WHERE key = 'ga_session_id') AS session_id,
sum((select value.int_value from unnest(event_params) where key = 'engagement_time_msec'))/1000 as timeOnSite_sec
FROM table_xxx
group by session_id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.