1

I run a website where I am including an older script version of Google Analytics. I really only need it to create the necessary cookies, not for tracking, so I set it to Local Server Mode. Link here.

This here is the script:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push('_setLocalGifPath','http://www.site.tld/sites/all/themes/site/images/1px.gif');
_gaq.push('_setLocalServerMode');
_gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

LocalServerMode should prevent Google Analytics from tracking visits to my website. It's not working though; visits are still being registered. Fiddler also shows that the local 1px.gif is never requested. Mostly setLocalServerMode does not appear to do anything.

1

The lines you've added to the javascript are missing square brackets (compare your code to the documentation you linked to). It should be:

_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_setLocalGifPath','http://www.site.tld/sites/all/themes/site/images/1px.gif']);
_gaq.push(['_setLocalServerMode']);
_gaq.push(['_trackPageview']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.