如何在analytics.js中为谷歌分析设置页面速度记录 [英] How to set up page speed logging for google analytics in analytics.js
问题描述
Google发布了新的 Analytics.js
( https://developers.google.com/analytics/devguides/collection/analyticsjs/ )。我希望使用它,除了网站速度,我已经完成了所有的设置。
Google released the new Analytics.js
(https://developers.google.com/analytics/devguides/collection/analyticsjs/). I would like to use it, and I already have everyting set up just fine, apart from site speed.
在旧 ga。 js
你可以用
In the "old" ga.js
you could do this with
_gaq.push(['_setSiteSpeedSampleRate', 50]);
这会设置它,所以50%的访问者会向sites analyed报告。
This would set it so 50% of the visitors would report sitespeed to analytics.
但是,对于新的 analytics.js
,我无法使其工作。我尝试了以下2:
However, for the new analytics.js
I cannot get it to work. I tried the following 2:
ga('send','setSiteSpeedSampleRate',50);
ga('setSiteSpeedSampleRate',50);
但没有结果。任何想法?
But no results. Any ideas?
推荐答案
啊,我找到了我的答案。它现在必须在像这样的create方法中设置:
Ah, I found my answer. It now has to be set in the create method like this:
ga('create', 'UA-39262824-7', {'siteSpeedSampleRate': 100});
可以使用的字段更多,可以在这里找到: Google Analytics网站速度采样率
There are more fields that can be used there, found it here: Google Analytics Site Speed Sample Rate
这篇关于如何在analytics.js中为谷歌分析设置页面速度记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!