[英]How to Integrate Google Analytics (PageSpeed and Pageview both) for Ajax Loaded Pages?
I am having a web application which runs completely on Ajax Loaded pages (For fast browsing). 我有一个完全在Ajax加载的页面上运行的Web应用程序(用于快速浏览)。 I integrated Google Analytics but it's not tracking speed of my Ajax Requests. 我集成了Google Analytics(分析),但它无法跟踪我的Ajax请求的速度。 Can anyone please tell me how to track speed? 谁能告诉我如何跟踪速度? So, that I can tweak my ajax loaded pages as per requirements. 因此,我可以根据需要调整ajax加载的页面。
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. 我见过有人建议使用ga('send','pagespeed')
但由于文档质量低下,我不知道如何实现此类ga
请求。
You can create two Custom Metrics with the scope hit
and the formatting integer
: 您可以使用范围hit
和格式integer
创建两个自定义指标:
metric1
for "AJAX load times" metric1
“ AJAX加载时间” metric2
for "AJAX page views" metric2
为“AJAX页面浏览量” 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: 然后发送带有AJAX指标的新page view
:
ga('send', 'pageview', {
'metric1': ajaxLoadTimeEnd,
'metric2': 1
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.