Skip to content

Instantly share code, notes, and snippets.

@aronwoost
Created May 31, 2011 12:11
Show Gist options
  • Save aronwoost/1000402 to your computer and use it in GitHub Desktop.
Save aronwoost/1000402 to your computer and use it in GitHub Desktop.
Exclude private ip addresses from google analytics tracking
(function(){
var re = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)|localhost/;
if(re.test(window.location.hostname)) return;
var _gaq=[['_setAccount','UA-23156659-1'],['_trackPageview'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment