From 48d49e96d6db282eb9686d31ebbc5cbbbdd4d966 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Mon, 3 Jun 2013 19:29:37 +0200 Subject: [PATCH] Update to Google Universal Analytics This is an optimized version of the official Google Universal Analytics snippet, based on http://mathiasbynens.be/notes/async-analytics-snippet. The only difference is that this version still uses `document.getElementsByTagName('script')[0]` instead of `document.scripts[0]` for Firefox < 9 support. Unminified, optimized code: (function(window, document, script, variableName, scriptElement, firstScript) { window['GoogleAnalyticsObject'] = variableName; window[variableName] || (window[variableName] = function() { (window[variableName].q = window[variableName].q || []).push(arguments) }); window[variableName].l = +new Date; scriptElement = document.createElement(script); firstScript = document.getElementsByTagName(script)[0]; scriptElement.src = '//www.google-analytics.com/analytics.js'; firstScript.parentNode.insertBefore(scriptElement, firstScript) }(window, document, 'script', 'ga')); ga('create', 'UA-XXXX-Y'); ga('send', 'pageview'); Minified: (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;e=o.createElement(i);r=o.getElementsByTagName(i)[0];e.src='//www.google-analytics.com/analytics.js';r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));ga('create','UA-XXXX-Y');ga('send','pageview'); Closes #1347 and #1369. --- CHANGELOG.md | 1 + index.html | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc8f557725..9d8451286e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### HEAD +* Update to Google Universal Analytics ([#1347](https://github.com/h5bp/html5-boilerplate/issues/1347)). * Update to jQuery 1.10.1. * Update to Normalize.css 1.1.2. diff --git a/index.html b/index.html index 4856dbadd3..8d6f72fceb 100644 --- a/index.html +++ b/index.html @@ -31,10 +31,12 @@