使用siteSpeedSampleRate设置的Google Analytics(分析)网站速度存在JavaScript错误 [英] Google Analytics Site Speed with siteSpeedSampleRate set has JavaScript error
问题描述
我想使用Google Analytics来监控网站速度。我将以下代码粘贴到我的HTML页面中:
I want to use Google Analytics to monitor site speed. I pasted the code below in my HTML page:
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics_debug.js','ga');
ga('create', 'UA-xxxxxxxx-x', 'domain.com', {'siteSpeedSampleRate': 100});
ga('send', 'pageview');
</script>
为了在我的本地主机中测试它,我使用 analytics_debug.js
代替 analytics.js
, UA-xxxxxxxx-x
作为真实ID, code> domain.com 作为真实的域名。 siteSpeedSampleRate
用于设置采样率(请参阅 ga('siteCpeedSampleRate>这个链接)。 send','pageview'):
In order to test it in my localhost, I use analytics_debug.js
instead of analytics.js
, UA-xxxxxxxx-x
as the real id, and domain.com
as the real domain name. siteSpeedSampleRate
is used to set the sample rate (see this link).
However, when my HTML page is visited, this JavaScript error happens when calling ga('send', 'pageview')
:
推荐答案
自2014.01.02起,当analytics_debug.js发送pagespeed定时信标时,此错误消息为标准配置。你的代码很好/正常工作。
As of 2014.01.02 this error message is standard in analytics_debug.js when it is sending a pagespeed timing beacon. Your code is fine / working corectly.
这篇关于使用siteSpeedSampleRate设置的Google Analytics(分析)网站速度存在JavaScript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!