简体   繁体   English

GA如何跟踪_trackPageView上的页面加载时间?

[英]How GA tracks page load time on _trackPageView?

I am stuck in a situation where I am left with no open end on a problem. 我陷入了这样一种情况,即我对问题没有开放的结果。 Let me put the problem first. 让我先把问题提出来。 We are trying to improve the performance of a webpage. 我们正在努力改善网页的效果。 We already have GA tracking on it. 我们已经对其进行了GA跟踪。 We fire '_trackPageView' on every page visit and we don't use any 'site speed tracking'. 我们在每次访问页面时都会触发'_trackPageView',我们不会使用任何“网站速度跟踪”。 In GA reporting we find the dom load time is around 5s and the page load time is around 13s. 在GA报告中,我们发现dom加载时间约为5秒,页面加载时间约为13秒。

To reduce the page load time, we want to load all the js scripts which are not necessary at load time, asynchronously after page load. 为了减少页面加载时间,我们希望在页面加载后异步加载加载时不需要的所有js脚本。 But the problem is we are not sure when the '_utm' image beacon (_tackaPageView) is fired. 但问题是我们不确定'_utm'图像信标(_tackaPageView)何时被触发。 If it is fired only after all the asyn resources are loaded, the page load time will increase further. 如果仅在加载所有asyn资源后触发,则页面加载时间将进一步增加。

So we tried debugging ga.js. 所以我们尝试调试ga.js. _pageTrackView is fired on window onload. _pageTrackView在window onload上触发。 After that there are no other GA requests fired. 之后,没有其他GA请求被解雇。 But the one thing which we are not able to figure out is, how GA is able to track the dom load time, page load time etc., There's no such trace in the request. 但是我们无法弄清楚的一件事是,GA如何能够跟踪dom加载时间,页面加载时间等,请求中没有这样的跟踪。 There is one epoch current time stamp, which is stored _ utma cookie, for instance ' _utma=1.417929071.1376029504.1376029504.1376040649.2'. 有一个纪元当前时间戳,存储_ utma cookie,例如' _utma = 1.417929071.1376029504.1376029504.1376040649.2'。 I learnt that the last but one parameter '1376040649' is the time stamp of when user entered the page in current session. 我了解到最后一个参数'1376040649'是用户在当前会话中输入页面的时间戳。 Remaining are all about the first visit, visitor id etc., There a request parameter which has no explanation anywhere 'utmht', for example 'utmht:1376040648577'. 剩下的都是关于第一次访问,访客ID等,有一个请求参数,没有任何解释'utmht',例如'utmht:1376040648577'。 '1376040648577' is a timestamp which is equal to the __utma timestamp except for the milliseconds part. '1376040648577'是一个时间戳,它等于__utma时间戳,除了毫秒部分。 Apart from this I don't find any time stamp or anything that is related to time. 除此之外,我没有找到任何与时间有关的时间戳或任何东西。 But GA tracks that all. 但GA追踪所有。 How? 怎么样? It has become a mystery to us. 它对我们来说已成为一个谜。 I tried figuring it out on numerous sources. 我尝试在众多来源上搞清楚。 Not one has any answer or explanation. 没有人有任何答案或解释。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Finally found the answer. 终于找到了答案。 Posting it as it might help someone else. 发布它可能会帮助其他人。

_trackPageLoadTime() is deprecated. 不推荐使用_trackPageLoadTime()

GA does track pageload by default on _pageTrackView , but not on all requests. GA会在_pageTrackView上默认跟踪页面加载,但不会跟踪所有请求。 It uses sampling rate on client side to send 'pageload timing' information to server. 它使用客户端的采样率将“页面加载定时”信息发送到服务器。 The default rate is 1%. 默认费率为1%。 That means for every 100 _pageTrackView requests, only one time ANOTHER request is sent with all page load information. 这意味着对于每100个_pageTrackView请求,只有一次ANOTHER请求与所有页面加载信息一起发送。 We can also set the client sampling rate to any value using _gaq.push(['_setSampleRate', '80']) . 我们还可以使用_gaq.push(['_setSampleRate', '80'])将客户端采样率设置为任何值。 When I set the sampling rate to 100, on all the requests, pageload time tracking beacon was also sent. 当我将采样率设置为100时,在所有请求中,还发送了页面加载时间跟踪信标。 There ends the mystery. 结束了这个谜。

This document might help, especially the notes section at the bottom which could point you in the right direction as to how page timings works. 本文档可能会有所帮助,尤其是底部的注释部分,它可以指向您正确的页面计时工作方向。

https://support.google.com/analytics/answer/1205784?hl=en https://support.google.com/analytics/answer/1205784?hl=en

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM