如何获取 Bigquery 中唯一页面浏览量的 Google Analytics 定义
How to get the Google Analytics definition of unique page views in Bigquery
https://support.google.com/analytics/answer/1257084?hl=en-GB#pageviews_vs_unique_views
我正在尝试计算 Google 分析在其界面上每天的唯一页面浏览量总和
我如何使用 bigquery 获得等效项?
有两种用法:
1) 一种是如原始链接文档所述,将完整的访问者用户 ID 及其不同的会话 ID:visitId 组合起来,并计算它们。
SELECT
EXACT_COUNT_DISTINCT(combinedVisitorId)
FROM (
SELECT
CONCAT(fullVisitorId,string(VisitId)) AS combinedVisitorId
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE' )
2) 另一个只是计算不同的 fullVisitorIds
SELECT
EXACT_COUNT_DISTINCT(fullVisitorId)
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE'
如果有人想在样本 public 数据集上进行试验,可以使用 tutorial how to add the sample dataset.
对于 uniquePageViews 你最好使用这样的东西:
SELECT
date,
SUM(uniquePageviews) AS uniquePageviews
FROM (
SELECT
date,
CONCAT(fullVisitorId,string(VisitId)) AS combinedVisitorId,
EXACT_COUNT_DISTINCT(hits.page.pagePath) AS uniquePageviews
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE'
GROUP BY 1,2)
GROUP EACH BY 1;
其他查询与我的 Google Analytics 帐户中的唯一浏览量指标不匹配,但以下匹配:
SELECT COUNT(1) as unique_pageviews
FROM (
SELECT
hits.page.pagePath,
hits.page.pageTitle,
fullVisitorId,
visitNumber,
COUNT(1) as hits
FROM [my_table]
WHERE hits.type='PAGE'
GROUP BY
hits.page.pagePath,
hits.page.pageTitle,
fullVisitorId,
visitNumber
)
因此,2022 年 EXACT_COUNT_DISTINCT() 似乎已弃用..
同样对我来说,
fullvisitorid+visitNumber+visitStartTime+hits.page.pagePath
的以下组合总是比上述解决方案更精确:
SELECT
SUM(Unique_PageViews)
FROM
(SELECT
COUNT(DISTINCT(CONCAT(fullvisitorid,"-",CAST(visitNumber AS string),"-",CAST(visitStartTime AS string),"-",hits.page.pagePath))) as Unique_PageViews
FROM
`mhsd-bigquery-project.8330566.ga_sessions_*`,
unnest(hits) as hits
WHERE
_table_suffix BETWEEN '20220307'
AND '20220313'
AND hits.type = 'PAGE')
https://support.google.com/analytics/answer/1257084?hl=en-GB#pageviews_vs_unique_views
我正在尝试计算 Google 分析在其界面上每天的唯一页面浏览量总和 我如何使用 bigquery 获得等效项?
有两种用法:
1) 一种是如原始链接文档所述,将完整的访问者用户 ID 及其不同的会话 ID:visitId 组合起来,并计算它们。
SELECT
EXACT_COUNT_DISTINCT(combinedVisitorId)
FROM (
SELECT
CONCAT(fullVisitorId,string(VisitId)) AS combinedVisitorId
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE' )
2) 另一个只是计算不同的 fullVisitorIds
SELECT
EXACT_COUNT_DISTINCT(fullVisitorId)
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE'
如果有人想在样本 public 数据集上进行试验,可以使用 tutorial how to add the sample dataset.
对于 uniquePageViews 你最好使用这样的东西:
SELECT
date,
SUM(uniquePageviews) AS uniquePageviews
FROM (
SELECT
date,
CONCAT(fullVisitorId,string(VisitId)) AS combinedVisitorId,
EXACT_COUNT_DISTINCT(hits.page.pagePath) AS uniquePageviews
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE
hits.type='PAGE'
GROUP BY 1,2)
GROUP EACH BY 1;
其他查询与我的 Google Analytics 帐户中的唯一浏览量指标不匹配,但以下匹配:
SELECT COUNT(1) as unique_pageviews
FROM (
SELECT
hits.page.pagePath,
hits.page.pageTitle,
fullVisitorId,
visitNumber,
COUNT(1) as hits
FROM [my_table]
WHERE hits.type='PAGE'
GROUP BY
hits.page.pagePath,
hits.page.pageTitle,
fullVisitorId,
visitNumber
)
因此,2022 年 EXACT_COUNT_DISTINCT() 似乎已弃用..
同样对我来说,
fullvisitorid+visitNumber+visitStartTime+hits.page.pagePath
的以下组合总是比上述解决方案更精确:
SELECT
SUM(Unique_PageViews)
FROM
(SELECT
COUNT(DISTINCT(CONCAT(fullvisitorid,"-",CAST(visitNumber AS string),"-",CAST(visitStartTime AS string),"-",hits.page.pagePath))) as Unique_PageViews
FROM
`mhsd-bigquery-project.8330566.ga_sessions_*`,
unnest(hits) as hits
WHERE
_table_suffix BETWEEN '20220307'
AND '20220313'
AND hits.type = 'PAGE')