Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up page speed logging for google analytics in analytics.js

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.

In the "old" ga.js you could do this with

_gaq.push(['_setSiteSpeedSampleRate', 50]);

This would set it so 50% of the visitors would report sitespeed to analytics.

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?

like image 785
Rene Pot Avatar asked Apr 09 '13 11:04

Rene Pot


People also ask

Can Google Analytics track page speed?

The Speed Suggestions report lets you see the speed of your website across metrics like Avg. Page Download Time (sec) and Avg. Server Response Time (sec). The report enables you to identify areas for improvement across your site and on specific pages so you can make your pages load faster.

How do I get page load time in Google Analytics?

Page Timings & User Timings reports > Distribution tab To get the speed detail for a specific page or resource, you can drill down into the item in the Explorer tab, and then click the Distribution tab to see the distribution of load/execution times.

What is GA (' Send pageview ');?

A pageview is simply each time the ga('send', 'pageview'); javascript is evoked. It usually happens just once per pageload, within the main Google Analytics code. However, if you place this line 10 times on the same page it will register 10 pageviews, when the user has only loaded one page.


1 Answers

Ah, I found my answer. It now has to be set in the create method like this:

ga('create', 'UA-39262824-7', {'siteSpeedSampleRate': 100});

There are more fields that can be used there, found it here: Google Analytics Site Speed Sample Rate

like image 183
Rene Pot Avatar answered Oct 05 '22 06:10

Rene Pot