如何在analytics.js中为谷歌分析设置页面速度日志 [英] How to set up page speed logging for google analytics in analytics.js

查看:19
本文介绍了如何在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% 的访问者会将站点速度报告给分析.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆