Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickgilmour/9d81e4205ea6df144d0d to your computer and use it in GitHub Desktop.
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.
<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