![](/img/trans.png)
[英]How to extract GA4 traffic session from BigQuery instead of user acquisition traffic?
[英]GA4 traffic source data do not match with bigquery
我尝试从 bigquery 导出流量源数据和事件归因并与 GA4(session_source 和 session_medium)匹配 我从 bigquery 中提取事件参数(源广告媒体)但两个数据源之间存在很大差距
有解决办法吗?
我尝试在 SQL 下面使用
with prep as (
select
user_pseudo_id,
(select value.int_value from unnest(event_params) where key = 'ga_session_id') as session_id,
max((select value.string_value from unnest(event_params) where key = 'source')) as source,
max((select value.string_value from unnest(event_params) where key = 'medium')) as medium,
max((select value.string_value from unnest(event_params) where key = 'name')) as campaign,
max((select value.string_value from unnest(event_params) where key = 'term')) as term,
max((select value.string_value from unnest(event_params) where key = 'content')) as coXXntent,
platform,
FROM `XXX`
group by
user_pseudo_id,
session_id,
platform
)
select
-- session medium (dimension | the value of a medium associated with a session)
platform,
coalesce(source,'(none)') as source_session,
coalesce(medium,'(none)') as medium_session,
coalesce(campaign,'(none)') as campaign_session,
coalesce(content,'(none)') as content,
coalesce(term,'(none)') as term,
count(distinct concat(user_pseudo_id,session_id)) as sessions
from
prep
group by
platform,
source_session,
medium_session,
campaign_session,
content,
term
order by
sessions desc
我也在尝试弄清楚为什么 BigQuery 无法正确匹配事件的来源和媒介。 我发现的问题是,即使链接中有 gclid 参数,它也会将源/媒体指定为 google/organic。 第二个问题是在将来源识别为直接来源方面存在巨大缺陷——在这种情况下,我根本没有这些事件参数。
这些值是有效的,但仅适用于获取用户的来源和媒体。
当我比较 UA 和 GA4 中的数据时,会话归因是正确的。 所以在导出到 BigQuery 时看起来像是一个问题。 我将此事报告给支持部门,正在等待回复。
我还注意到来源/媒体在 BigQuery 和 GA4 之间不一致,就像 Justyna 评论的那样,我的很多来源/媒体都是通过 google/organic 获得的,即使它们不是。 我希望 Justyna 在有解决方案时会在这里发布。
查看您的代码,我可以看到另外 2 个会导致差异的区域
1)
count(distinct concat(user_pseudo_id,session_id)) as sessions
这将只捕获具有有效 pseudo_id 和 session_id 的事件,这是正确的计数方式,但在我的数据中往往有一些没有 id 的事件为空,所以你的会话计数包括它们但 GA4 确实如此。所以使用你的首选如果这对您来说是个问题,则计算空值的方法。
2): 你也在做一个精确的计数,这也是正确的,但 GA4 做了一个近似匹配,详情见下面的链接。
使用以上两种技术,我可以更接近 GA4 会话数,但它们仍然没有正确归因
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.