我尝试通过Bigquery使用Google Analytics数据撰写查询,以了解网页速度对我网站的影响。有很多研究讨论了慢速网站网站对转化的影响,并且我希望运行类似的分析(for example)。
目前我有以下查询,但看起来hit.time会随着totals.pageviews的增加而增加。如果我没有弄错,这必须意味着hits.time被注册为网站上的总时间,而不一定是给定页面上的总时间。
SELECT
ROUND(AVG(totals.pageviews),0) AS avg_page_views,
CASE
WHEN hits.time <= 1000 THEN '0 Second'
WHEN hits.time BETWEEN 1001 AND 2000 THEN '1 Second'
WHEN hits.time BETWEEN 2001 AND 3000 THEN '2 Second'
WHEN hits.time BETWEEN 3001 AND 4000 THEN '3 Second'
WHEN hits.time BETWEEN 4001 AND 5000 THEN '4 Second'
WHEN hits.time BETWEEN 5001 AND 6000 THEN '5 Second'
WHEN hits.time BETWEEN 6001 AND 7000 THEN '6 Second'
WHEN hits.time BETWEEN 7001 AND 8000 THEN '7 Second'
WHEN hits.time BETWEEN 8001 AND 9000 THEN '8 Second'
WHEN hits.time BETWEEN 9001 AND 10000 THEN '9 Second'
WHEN hits.time BETWEEN 10001 AND 10000 THEN '10 Second'
ELSE 'More than 10 Seconds'
END hits.time
FROM
[session.ga_sessions_20150501]
WHERE
hits.page.pagePath != ''
and totals.bounces IS NOT NULL
AND hits.hitnumber >= 1
AND hits.time > 0
AND hits.type = 'PAGE'
AND hits.page.pagePath LIKE '%/work/apps/business/%'
GROUP BY 1,2
ORDER BY 1
LIMIT 2000
;
有关如何更改此查询以提高每页速度的任何想法,以便可以使用诸如转化或跳出率之类的内容绘制图表?我知道这些数据存在于Google Analytics中,但我无法通过Bigquery API或Google Analytics(分析)找到合适的维度。
提前致谢!
答案 0 :(得分:1)
你完全不在这里。
hits.time
表示其他内容:
注册此匹配后visitStartTime之后的毫秒数。第一个命中的命中时间为0。
因此,测量自访问开始时间起所经过的时间,而不是所有加载时间。它是启动时的请求时间,与DOM无关。
AFAIK没有指标可以为您提供DOM加载时间。
架构:
答案 1 :(得分:1)
现在可以了,我想它是在最初的问题后添加的。
以下将页面加载时间正确匹配回 GA 界面。
with speed_metrics as (
SELECT
date,
device.browser,
device.operatingSystem,
device.deviceCategory,
geoNetwork.country,
visitorId,
fullVisitorId,
IF(totals.visits=1,CONCAT(fullVisitorId, CAST(visitId AS STRING)), null) AS
session_id,
hits.hitNumber,
hits.latencyTracking.pageLoadSample,
hits.latencyTracking.pageLoadTime,
hits.latencyTracking.pageDownloadTime,
hits.latencyTracking.redirectionTime,
hits.latencyTracking.speedMetricsSample,
hits.latencyTracking.domainLookupTime,
hits.latencyTracking.serverConnectiontime,
hits.latencyTracking.serverResponseTime,
hits.latencyTracking.domLatencyMetricsSample,
hits.latencyTracking.domInteractiveTime,
hits.latencyTracking.domContentLoadedTime
FROM `river-island-clothing-co-ltd.155484603.ga_sessions_20210308`
, unnest (hits) as hits
)
select
avg(pageLoadTime) / 1000 as avg_load_time ,
sum(pageLoadTime) / count(distinct (concat(session_id, cast(hitNumber as string)))) /
1000 as also_avg_load_time
from speed_metrics
where pageLoadSample is not null
LIMIT 1000
需要注意的有用部分是结果是从您的整体浏览量/会话的样本中生成的,请注意 where 子句。由于这是在命中级别(在本例中为综合浏览量),因此记录数 = 综合浏览量数,因此两种聚合生成的结果相同!