Skip to content

Instantly share code, notes, and snippets.

@dopsmain
Forked from kirps/localga.js
Created March 14, 2017 09:55
Show Gist options
  • Save dopsmain/8429a8ae26442609d7048ec629d7a7f1 to your computer and use it in GitHub Desktop.
Save dopsmain/8429a8ae26442609d7048ec629d7a7f1 to your computer and use it in GitHub Desktop.
Replace default ga.js location with local file.
$(document).ready(function(e) {
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
//ga.src = ('https:' == document.location.protocol ? '<a href="https://ssl">https://ssl</a>' : '<a href="http://www">http://www</a>') + '.<a href="http://google-analytics.com/ga.js">google-analytics.com/ga.js</a>';
//replace the google provided src attribute with the local file starting from the www directory
ga.src = 'ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment