BigQuery 问题:同一访问者的时间戳如何以及为啥相同?
Posted
技术标签:
【中文标题】BigQuery 问题:同一访问者的时间戳如何以及为啥相同?【英文标题】:BigQuery issue: how & why the timestamp can be the same for the same visitor?BigQuery 问题:同一访问者的时间戳如何以及为什么相同? 【发布时间】:2017-03-17 11:54:52 【问题描述】:对于通过 2 个不同浏览器访问网站的同一访问者,我在 BigQuery 中的“visitStartTime”时间戳字段中遇到以下问题? 如何以及为什么可能(时间戳应该改变,因为通常使用基于正数的时间戳计算秒数指定自 unix 纪元(1970-01-01 00:00:00 UTC)以来的秒数?
产生截图结果的查询:
SELECT
DATE,
MAX(CASE
WHEN customDimensions.index = 1 THEN customDimensions.value END) AS CUSTOMDIMENSIONS_VALUE, visitNumber, fullvisitorid, visitStartTime, SEC_TO_TIMESTAMP(visitStartTime) AS humain, TIME (visitStartTime+3600 ) AS Paris_timezone, hits.hour, hits.minute, CONCAT(fullvisitorid, STRING(visitid)) AS sessionid, MAX(CASE
WHEN hits.customDimensions.index = 11 THEN hits.customDimensions.value END) AS localproductname,
device.deviceCategory,
hits.page.pagePath,
IFNULL(hits.page.pagePathLevel2, '') AS HITS_PAGE_PAGEPATHLEVEL2,
IFNULL(hits.page.pagePathLevel3, '') AS HITS_PAGE_PAGEPATHLEVEL3,
MAX(CASE
WHEN hits.customDimensions.index = 14 THEN hits.customDimensions.value END) AS assetpurpose,
hits.hitNumber,
FROM (FLATTEN([85801771.ga_sessions_20161025], customDimensions.value )),
(FLATTEN([85801771.ga_sessions_20161026], customDimensions.value )),
WHERE
AND customDimensions.value != "null"
AND customDimensions.value = "968a9587-0614-4155-9597-bf17aef42125"
AND hits.type = 'PAGE'
AND (customDimensions.index = 1
OR hits.customDimensions.index = 11
OR hits.customDimensions.index = 14
OR hits.customDimensions.index = 27 )
GROUP EACH BY
DATE,
visitStartTime,
humain,
Paris_timezone,
hits.hour,
hits.minute,
fullVisitorId,
sessionid,
visitNumber,
device.deviceCategory,
hits.page.pagePath,
HITS_PAGE_PAGEPATHLEVEL2,
HITS_PAGE_PAGEPATHLEVEL3,
hits.hitNumber,
LIMIT
100000
【问题讨论】:
请编辑您的问题以显示您遇到问题的代码的Minimal, Complete, and Verifiable example,然后我们可以尝试帮助解决具体问题。你也可以阅读How to Ask。 【参考方案1】:根据列名,我假设您从 Google Analytics (https://support.google.com/analytics/answer/3437719?hl=en) 获得了这些数据。文档说
表中的每一行对应于 Google Analytics(分析)中的一个会话 360.
因此visitStartTime
对应于会话的开始。从您所附的屏幕截图中不清楚是否发生了行扁平化,但如果发生了 - 这将解释它。
【讨论】:
谢谢摩沙,我加个查询例子;它可能会对你有所帮助。 SELECT DATE, MAX(CASE WHEN customDimensions.index = 1 THEN customDimensions.value END) AS CUSTOMDIMENSIONS_VALUE, visitNumber, fullvisitorid, visitStartTime, SEC_TO_TIMESTAMP(visitStartTime) AS humain, TIME (visitStartTime+3600) as Paris_timezone , hits.hour, hits.minute, CONCAT(fullvisitorid, STRING(visitid)) AS sessionid, MAX(CASE 当 hits.customDimensions.index = 11 THEN hits.customDimensions.value END) AS localproductname, device.deviceCategory, hits.page.pagePath, IFNULL(hits.page.pagePathLevel2, '') AS HITS_PAGE_PAGEPATHLEVEL2 , IFNULL(hits.page.pagePathLevel3, '') AS HITS_PAGE_PAGEPATHLEVEL3, MAX(CASE WHEN hits.customDimensions.index = 14 THEN hits.customDimensions.value END) 作为资产用途, hits.hitNumber, FROM (FLATTEN([85801771.ga_sessions_20161025] , customDimensions.value )), (FLATTEN([85801771.ga_sessions_20161026], customDimensions.value )), WHERE AND customDimensions.value != "null" AND customDimensions.value = "968a9587-0614-4155-9597-bf17aef42125" AND hits.type = 'PAGE' AND (customDimensions.index = 1 OR hits.customDimensions.index = 11 OR hits.customDimensions.index = 14 OR hits.customDimensions.index = 27)按日期分组,visitStartTime,humain,Paris_timezone,hits.hour,hits.minute,fullVisitorId,sessionid,visitNumber,设备.deviceCategory, hits.page.pagePath, HITS_PAGE_PAGEPATHLEVEL2, HITS_PAGE_PAGEPATHLEVEL3, hits.hitNumber, LIMIT 100000 @sPujade - 请不要使用 cmets 来显示您的代码 - 只需将其添加到您的原始问题中!以上是关于BigQuery 问题:同一访问者的时间戳如何以及为啥相同?的主要内容,如果未能解决你的问题,请参考以下文章