-
-
Save nateberkopec/a43f3e29d9583df33406 to your computer and use it in GitHub Desktop.
Revisions
-
nateberkopec revised this gist
Nov 5, 2015 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,9 +5,8 @@ This gist applies the theory from Ilya Grigorik's [Script-injected "async script ```html <!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview--> <script> !function(n,t){n.GoogleAnalyticsObject=t,n[t]=n[t]||function(){(n[t].q=n[t].q||[]).push(arguments)},n[t].l=1*new Date}(window,"ga"); ga('create', 'UA-XXXX-Y', 'auto'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT ga('send', 'pageview'); </script> <!-- End Google Analytics Part 2 --> -
tomfuertes revised this gist
Jun 8, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # De-'Async Inject' Universal Analytics This gist applies the theory from Ilya Grigorik's [Script-injected "async scripts" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/) on the default Universal Analytics snippet. TLDR place this above the CSS in the `<head>` of your document ```html <!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview--> @@ -13,7 +13,7 @@ This gist applies the theory from Ilya Grigorik's [Script-injected "async script <!-- End Google Analytics Part 2 --> ``` And then place this below your CSS in the `<head>`: ```html <!-- Google Analytics Part 2: load analytics.js--> -
tomfuertes revised this gist
Jun 8, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # De-'Async Inject' Universal Analytics This gist applies the theory from Ilya Grigorik's [Script-injected "async scripts" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/) on the default Universal Analytics snippet. TLDR place this above the CSS in the `<head>` of your document ```html <!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview--> @@ -13,7 +13,7 @@ This gist applies the theory from Ilya Grigorik's [Script-injected "async script <!-- End Google Analytics Part 2 --> ``` And then place this below your CSS in the `<head>`: ```html <!-- Google Analytics Part 2: load analytics.js--> -
tomfuertes revised this gist
Jun 8, 2014 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,24 @@ # De-'Async Inject' Universal Analytics This gist applies the theory from Ilya Grigorik's [Script-injected "async scripts" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/) on the default Universal Analytics snippet. TLDR place this above the CSS in the <head> of your document ```html <!-- Google Analytics Part 1: Creates window.ga, sets account, and queues pageview--> <script> (function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){ (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga"); ga('create', 'UA-XXXX-Y'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT ga('send', 'pageview'); </script> <!-- End Google Analytics Part 2 --> ``` And then place this below your CSS in the <head>: ```html <!-- Google Analytics Part 2: load analytics.js--> <script async src='//www.google-analytics.com/analytics.js'></script> <!-- End Google Analytics Part 2 --> ``` * [1.default.html](#file-1-default-html) - Pulled from [Introduction to Analytics.js / Tracking Code Quick Start](https://developers.google.com/analytics/devguides/collection/analyticsjs/) -
tomfuertes revised this gist
Jun 8, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ By now I'm sure we've all read and thought about Ilya Grigorik's [Script-injecte <!-- Google Analytics --> <script> (function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){ (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga"); ga('create', 'UA-XXXX-Y'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT ga('send', 'pageview'); </script> -
tomfuertes revised this gist
Jun 8, 2014 . 2 changed files with 6 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,6 @@ # De-'Async Inject' Universal Analytics By now I'm sure we've all read and thought about Ilya Grigorik's [Script-injected "async scripts" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/). This post walks through a synthesis of that information on the default Universal Analytics snippet: ```html <!-- Google Analytics --> @@ -17,4 +12,8 @@ By now I'm sure we've all read and thought about Ilya Grigorik's [Script-injecte </script> <script async src='//www.google-analytics.com/analytics.js'></script> <!-- End Google Analytics --> ``` * [1.default.html](#file-1-default-html) - Pulled from [Introduction to Analytics.js / Tracking Code Quick Start](https://developers.google.com/analytics/devguides/collection/analyticsjs/) * [2.jsniced.html](#file-2-jsniced-html) - Pulled from [Optimizing the Google Analytics Snippet](http://mathiasbynens.be/notes/async-analytics-snippet#universal-analytics) * [3.refactored.html](#file-3-refactored-html) - Removes async injected parts + dead variables. -
tomfuertes renamed this gist
Jun 8, 2014 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,16 @@ By now I'm sure we've all read and thought about Ilya Grigorik's [Script-injecte * [0.result.html](#file-0-result-html) - End Result * [1.default.html](#file-1-default-html) - Pulled from [Introduction to Analytics.js / Tracking Code Quick Start](https://developers.google.com/analytics/devguides/collection/analyticsjs/) * [2.jsniced.html](#file-2-jsniced-html) - Pulled from [Optimizing the Google Analytics Snippet](http://mathiasbynens.be/notes/async-analytics-snippet#universal-analytics) * [3.refactored.html](#file-3-refactored-html) - Removes async injected parts + dead variables. ```html <!-- Google Analytics --> <script> (function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){ (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga") ga('create', 'UA-XXXX-Y'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT ga('send', 'pageview'); </script> <script async src='//www.google-analytics.com/analytics.js'></script> <!-- End Google Analytics --> ``` -
tomfuertes revised this gist
Jun 8, 2014 . 2 changed files with 12 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ <!-- Google Analytics --> <script> (function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){ (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga") ga('create', 'UA-XXXX-Y'); // REPLACE UA-XXXX-Y w/ YOUR ACCOUNT ga('send', 'pageview'); </script> <script async src='//www.google-analytics.com/analytics.js'></script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # De-'Async Inject' Universal Analytics By now I'm sure we've all read and thought about Ilya Grigorik's [Script-injected "async scripts" considered harmful](https://www.igvita.com/2014/05/20/script-injected-async-scripts-considered-harmful/). This post walks through a synthesis of that information on the default Universal Analytics snippet. * [0.result.html](#file-0-result-html) - End Result * [1.default.html](#file-1-default-html) - Pulled from [Introduction to Analytics.js / Tracking Code Quick Start](https://developers.google.com/analytics/devguides/collection/analyticsjs/) * [2.jsniced.html](#file-2-jsniced-html) - Pulled from [Optimizing the Google Analytics Snippet](http://mathiasbynens.be/notes/async-analytics-snippet#universal-analytics) * [3.refactored.html](#file-3-refactored-html) - Removes async injected parts + dead variables. -
tomfuertes renamed this gist
Jun 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
tomfuertes created this gist
Jun 8, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <!-- Google Analytics --> <script>(function(e,t){e.GoogleAnalyticsObject=t;e[t]=e[t]||function(){ (e[t].q=e[t].q||[]).push(arguments)};e[t].l=1*new Date})(t,"ga") ga('create', 'UA-XXXX-Y'); ga('send', 'pageview'); </script> <script async src='//www.google-analytics.com/analytics.js'></script> <!-- End Google Analytics --> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ <!-- Google Analytics --> <script> (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-XXXX-Y', 'auto'); ga('send', 'pageview'); </script> <!-- End Google Analytics --> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <!-- Google Analytics --> <script> (function(window, document, strScript, url, variableName, scriptElement, firstScript) { window['GoogleAnalyticsObject'] = variableName; window[variableName] = window[variableName] || function() { (window[variableName].q = window[variableName].q || []).push(arguments); }; window[variableName].l = 1 * new Date(); scriptElement = document.createElement(strScript), firstScript = document.getElementsByTagName(strScript)[0]; scriptElement.async = 1; scriptElement.src = url; firstScript.parentNode.insertBefore(scriptElement, firstScript) })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); ga('create', 'UA-XXXX-Y'); ga('send', 'pageview'); </script> <!-- End Google Analytics --> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ <!-- Google Analytics --> <script> (function(window, variableName) { window.GoogleAnalyticsObject = variableName; window[variableName] = window[variableName] || function() { (window[variableName].q = window[variableName].q || []).push(arguments); }; window[variableName].l = 1 * new Date(); })(window, 'ga'); ga('create', 'UA-XXXX-Y'); ga('send', 'pageview'); </script> <script async src='//www.google-analytics.com/analytics.js'></script> <!-- End Google Analytics -->