Steve
Steve

Reputation: 4898

Enabling page load samples for Google Analytics Site Speed

When I look at Behavior | Site Speed |Overview in GA I get the message:

"0 of pageviews sent page load sample"

How are these enabled? Or is this a ga() call you have to make from DOM Ready?

Thanks

Upvotes: 6

Views: 1940

Answers (1)

ganders
ganders

Reputation: 7433

You need to set your sample set higher. I believe the default is only 10%. I'll paste code below once I get it from my BitBucket repo.

Notice the "siteSpeedSsampleRate" property. I set mine to 100% because I'm greedy and want to know about ALL page views. Helps when I don't have more than 100k page views per month...

(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.js', 'ga');

ga('create', 'UA-xxxxxxxxx-x', {'siteSpeedSampleRate': 100});
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');

FYI - this is the part that is needed:

{'siteSpeedSampleRate': 100}

Upvotes: 5

Related Questions