I am having a web application which runs completely on Ajax Loaded pages (For fast browsing). I integrated Google Analytics but it's not tracking speed of my Ajax Requests. Can anyone please tell me how to track speed? So, that I can tweak my ajax loaded pages as per requirements.
I've seen some people were suggesting to use ga('send','pagespeed')
but I don't know how to implement such ga
requests because of low-quality documentations.
You can create two Custom Metrics with the scope hit
and the formatting integer
:
metric1
for "AJAX load times"metric2
for "AJAX page views"When the request is sent, start a timer:
var ajaxLoadTimeStart = Date.now();
When the response is received, end the timer:
var ajaxLoadTimeEnd = (Date.now() - ajaxLoadTimeStart)/1000;
Then send a new page view
with the AJAX metrics:
ga('send', 'pageview', {
'metric1': ajaxLoadTimeEnd,
'metric2': 1
});