我正在尝试将“时间”或“日期”作为维度添加到Big Query中的Google Analytics(分析)查询中...如何将每日或每月的“日期”添加到此查询中?我了解如何过滤WHERE语句中的日期,但不了解如何在显示的结果中添加“日期”字段。参见附带的代码。
错误的几个_TableSuffix选项
SELECT
hits.page.pagePath,
COUNT(*) AS pageviews
FROM
`xyz.33759344.ga_sessions_*` AS GA,
UNNEST(GA.hits) AS hits
WHERE
hits.type = 'PAGE'
AND
_TABLE_SUFFIX BETWEEN '20190201' AND '20190331'
AND
hits.page.pagePath LIKE '%step/checkout'
GROUP BY
hits.page.pagePath
ORDER BY
pageviews DESC
我想将每天和(作为单独的查询)每月计数添加到代码中。
答案 0 :(得分:1)
要按日期显示提示,您可以简单地按GROUP BY列日期。请参阅以下使用公共GA示例数据的示例。 (还请检查BigQuery Datetime Functions,了解如何从日期中提取月份)
#standardSQL
SELECT hits.page.pagePath,
COUNT(*) AS pageviews, date
FROM
`bigquery-public-data.google_analytics_sample.ga_sessions_*` AS GA,
UNNEST(GA.hits) AS hits
WHERE
hits.type = 'PAGE'
AND
_TABLE_SUFFIX BETWEEN '20170701' AND '20170801'
AND
hits.page.pagePath LIKE '%/google+redesign/electronics'
GROUP BY
hits.page.pagePath, date
ORDER BY
pageviews DESC