I have added the JavaScript that I need to the bottom of my pages so that I can make use of Google Analytics. Only problem is that I am sure that it is counting all my devel
We setup a 2nd google analytics tracking code for development and QA work -- actually comes in handy when you want to test your analytics integration, also ensures one doesn't have bleedover into production stats.
Probably not helpful to you, but I solved this problem by writing a custom ASP.NET server control that injects the required JavaScript. I then added the live URL to web.config and then only made the control visible when the host name matched the live URL in web.config.
Yeah, you go into Analytics Settings, edit your site, and +Add Filter to define a filter that excludes your IP address.
Past data is not regenerated with filters applied, so you'll only have the benefit of them moving forward.
I like the simple approach of using javascript. It works anywhere.
<script type="text/javascript">
if (document.location.hostname.search("myproductiondomainname.com") !== -1) {
//google analytics code goes here
}
</script>
Add this line before your Google Analytics async code runs to disable tracking for that web property ID:
window['ga-disable-UA-XXXXXX-Y'] = true;
UA-XXXXXX-Y
corresponds to the web property ID on which you would like to disable tracking.
From: https://developers.google.com/analytics/devguides/collection/gajs/
Like people are mentioning you can either host the google-analytics.com domain locally or setup a function to see if you are working in your development network.
Keep in mind if http://www.google-analytics.com/ga.js does not load and your using onclick javascript functions to help track clicks on page elements.
IE: onclick="javascript:pageTracker._trackPageview('/made/up/folder/reference');
Your going to have JavaScript errors that will stop jQuery or other robust JavaScript functions from functioning.