A very simple way to disable Google Analytics when you don’t want your visit to be registered (for instance when you’re working on your CSS or making a page with a template that embed the GA tracker) : just add a variable to load the tracker (or not) depending on the context :
Here’s my version :
<script type="text/javascript">
var testmode=false;
if(/taiste.acadis.org/.test(window.location.host)
|| /.*admin.*/.test(window.location.pathname)
|| /.*noga.*/.test(window.location.search)
|| /.*noga.*/.test(window.location.hash))
testmode=true;
if(!testmode){
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">
if(!testmode){
try {
var pageTracker = _gat._getTracker("...");
ageTracker._trackPageview();
} catch(err) {}
}
</script>
Here, GA won’t be loaded for urls like example.com#noga, test.example.com and so on…