How does GA track page load time on _trackPageView?

I was stuck in a situation where I was left without an open end to the problem. Let me first pose the problem. We are trying to improve web page performance. We already have GA tracking on it. We run "_trackPageView" every time we visit the page, and we do not use "site speed tracking". In GA reports, we find that the dom load time is about 5 seconds and the page load time is about 13 seconds.

To reduce page load time, we want to load all js scripts that are not needed at load time, asynchronously after page loading. But the problem is that we are not sure when the image arrow "_utm" (_tackaPageView) is launched. If it is launched only after loading all asyn resources, the page load time will increase.

So, we tried debugging ga.js. _pageTrackView starts when the window loads. After this, there were no other HS requests. But the only thing that we cannot understand is how GA can track loading time, page loading time, etc. There is no such trace in the request. There is one timestamp that is stored by _utma cookie, for example '_utma = 1.417929071.1376029504.1376029504.1376040649.2'. I found out that the last but one parameter “1376040649” is the timestamp when the user entered the page in the current session. All that was left was the first visit, visitor ID, etc. There is a query parameter that has no explanation anywhere else for 'utmht', for example 'utmht: 1376040648577'. '1376040648577' is a timestamp that is equal to the __utma timestamp, with the exception of a fraction of a millisecond. In addition to this, I do not find a single time stamp or anything related to time. But GA keeps track of everything. How? This has become a mystery to us. I tried to figure out numerous sources. No one has an answer or explanation.

Any help would be greatly appreciated.

+4
source share
2 answers

Finally found the answer. Posting as it may help someone else.

_trackPageLoadTime() deprecated.

GA defaults to pageload tracking in _pageTrackView , but not for all requests. It uses client-side sampling rate to send pageload timing information to the server. The default bid is 1%. This means that for every 100 _pageTrackView requests, an ANOTHER request is sent only once with all the page load information. We can also set the client's sampling rate to any value using _gaq.push(['_setSampleRate', '80']) . When I set the sampling rate to 100, a pageload time tracking beacon is also sent for all requests. There ends the mystery.

+6
source

This document may help, especially the notes section below, which may point you in the right direction regarding how page timings work.

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

Hope this helps

+2
source

Source: https://habr.com/ru/post/1496114/


All Articles