Practical Web Programming

Thursday, June 20, 2013

Track across sub-domains in google analytics

Google analytics, tracks sub-domain separately. If you don't want that, add the following line in the tracking code:

_gaq.push(['_setDomainName', '.kabalweg.com']);

So your tracking code will look like this:

<script type="text/javascript">
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']);
var _gaq = _gaq || [];
_gaq.push(['_trackPageview']);
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setDomainName', '.kabalweg.com']);
(function() {
_gaq.push(['_trackPageview']);
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
(fugna.cstrico=n(()'h{ttps:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var ga = document.createElement('script'); ga.type =
var s = document.getElementsByTagName('script')[0];
'text/javascript'; ga.async = true;
s.parentNode.insertBefore(ga, s);
ga.src = ('https:' == document.location.protocol ?
})();
'https://ssl' : 'http://www') + '.google- analytics.com/ga.js';
</script>
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
 


0 comments:

Recent Post