Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics Site Speed with siteSpeedSampleRate set has JavaScript error

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>

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'):

Missing required field '"timingCategory"' for hit of type '"timing"' analytics_debug.js:8
log analytics_debug.js:8
O analytics_debug.js:7
b analytics_debug.js:15
Ec analytics_debug.js:15
nc analytics_debug.js:21
gc.(anonymous function).execute analytics_debug.js:19
ad.(anonymous function).send analytics_debug.js:45
Y.b.(anonymous function) analytics_debug.js:32
(anonymous function) analytics_debug.js:46
Sc analytics_debug.js:33
(anonymous function) analytics_debug.js:33
Missing required field '"timingVar"' for hit of type '"timing"' analytics_debug.js:8
log analytics_debug.js:8
O analytics_debug.js:7
b analytics_debug.js:15
Ec analytics_debug.js:15
nc analytics_debug.js:21
gc.(anonymous function).execute analytics_debug.js:19
ad.(anonymous function).send analytics_debug.js:45
Y.b.(anonymous function) analytics_debug.js:32
(anonymous function) analytics_debug.js:46
Sc analytics_debug.js:33
(anonymous function) analytics_debug.js:33
like image 313
user2806524 Avatar asked Oct 22 '22 00:10

user2806524


1 Answers

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.

like image 71
TomFuertes Avatar answered Oct 23 '22 18:10

TomFuertes