Created
July 7, 2014 22:07
-
-
Save patrickgilmour/9d81e4205ea6df144d0d to your computer and use it in GitHub Desktop.
Google Analytics - only track live/production site hits and don't send hits from localhost or other development domains.
This file contains 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 characters
<script> | |
// Replace MYLIVEDOMAIN.com with your domain. | |
// Google Analytics will now not receive hits from cloned development versions of your site on localhost etc. | |
// Also checkout `Block Yourself from Analytics` plugin for Chrome | |
// see also: http://stackoverflow.com/questions/1251922/is-there-a-way-to-stop-google-analytics-counting-development-work-as-hits | |
if (document.location.hostname.search("MYLIVEDOMAIN.com") !== -1) { | |
/* Google Analytics Code here */ | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment