Google Analytics through HTTPS or not? Loadtimes per device and more

More and more sites are moving towards HTTPS in the past months. Google claimed it can be used as an SEO ranking signal and privacy organizations advice it so you give your visitors more privacy.

Google Analytics works fine on both HTTP and HTTPS sites. In the basic tracking script you see this line:


It's a protocol independent URL that will fetch the analytics.js file from HTTP or HTTPS based on the site's protocol where the script is loaded. But Google Analytics offers an extra option to do the tracking in HTTPS also. Take your basic tracking code and add the forceSSL line:

ga('create', 'UA-XXXXX-X');
ga('set', 'anonymizeIp', true);
ga('set', 'forceSSL', true);
ga('send', 'pageview');

(I also add the anonymizeIp line by default to give my visitors just a little bit more privacy).

When applied, all tracking calls the Google Analytics script generates will be send through HTTPS.

The technical setup

To test the impact of this configuration I created this simple script:

var ssl = false; var datum = new Date; var stamp = datum.getTime(); var last = (stamp + "").substr(12); var even = stamp % 2;
if (even == 0) { ssl = true; }

if (ssl) { ga('set', 'forceSSL', true); }

var datum = new Date; start_stamp = datum.getTime();

ga('send', 'pageview', { 'hitCallback': function() {
var datum = new Date; end_stamp = datum.getTime();
ga('send', 'timing', 'ssl-or-not', ssl, end_stamp - start_stamp);

Based on the actual timestamp it divides all pageviews 50/50 over the forceSSL options 'on' or 'off'. Then it uses the hitCallback function (that is called after a successful tracking) to track the amount of time that was needed to complete the tracking. And finally it uses the not so known timing function of Google Analytics to track the loadtime of the Google Analytics tracking with the forceSSL parameter (on/off) included. The results look like this:


Impact on loadtime

The above-mentioned script runs for some time now, and it generates some interesting results. First the main results (the 0 means HTTP and 1 means HTTPS turned on):


On average the tracking takes about 760 milliseconds to complete and send a 'complete' signal back. For HTTP it's 670ms and HTTPS 850ms. That's an increase of 27% in time that is needed to complete the tracking through SSL.

Let's have a look at the numbers per country:


For most countries the HTTPS tracking is slower than HTTP except for the Unites States...? I have some technical clues about what could cause that, but I'm guessing someone in the comments can it explain much better 😉

The numbers per device category:


Nothing odd here, mobile devices tend to be somewhat slower than desktop devices, and HTTPS adds just an extra bit of slowness.

I also did some research in the differences per browser, and found that Chrome was by far the slowest, but that could be because a lot of mobile devices use Chrome.


Although the HTTPS tracking is slower I still advice you to turn the forceSSL function/option on. The tracking call is asynchronous and will not slow down your site. And while you're at it, perhaps think of turning your entire site to HTTPS. It the future it could be a positive SEO factor, although it doesn't looks like Google made this change already according to Searchmetrics.

Click to activate social bookmarks