【发布时间】:2018-12-04 13:04:09
【问题描述】:
我正在尝试从 BigQuery 导出命中级别的 Google Anlaytics 自定义维度和一些事件。到目前为止,自定义维度导出不起作用。
我正在使用 LegacySQL。因为这是更大查询的一部分,我现在不想切换到 StandardSQL。
SELECT
clientId,
totals.timeOnSite,
hits.page.pagePath,
MAX(IF(customDimensions.index=1, customDimensions.value, NULL)) WITHIN
customDimensions AS cd1,
trafficSource.source,
SUM(COUNT(CASE WHEN (hits.eventInfo.eventCategory = 'Download' AND hits.type
= 'EVENT' AND hits.eventInfo.eventAction = 'pdf') THEN
hits.eventInfo.eventAction END)) AS Downloads,
SUM(COUNT(CASE WHEN (hits.eventInfo.eventLabel = 'search-header' OR
hits.eventInfo.eventLabel = 'search-mainpage') AND hits.type = 'EVENT' THEN
hits.eventInfo.eventLabel END)) AS Search,
FROM TABLE_DATE_RANGE([xxxxxx.ga_sessions_],
TIMESTAMP('2018-11-25'), TIMESTAMP('2018-11-25')) WHERE hits.page.pagePath LIKE '%xyz%'
GROUP BY 1,2,3,4,5
LIMIT 100;
查询失败并显示“错误:范围和非范围聚合函数的混合无效”关于如何解决此问题的任何想法? 亲切的问候!
【问题讨论】:
-
您应该添加表格结构和一些带有输入/输出的示例
-
我的查询在与我的分析视图链接的整个谷歌分析表上运行。结果工作正常,除非我在 customDimensions AS cd1 中添加行 MAX(IF(customDimensions.index=1, customDimensions.value, NULL)),因此自定义维度查询无法正常工作。自定义维度 cd1 显示在浏览器中输入的真实 URL。
标签: sql google-analytics google-bigquery legacy-sql