Google Analytics over cross domain or multiple Domains

[img:Google Analytics over cross domain or multiple Domains]

Google always recommends using separate analytical IDs and script for different domains. That is the best solution as we can track total stats of each domain properly. But sometimes we may face some scenarios where you need to track the stats of all domains.

But the Google Analytics documents have no mention on this. But there are ways to implement this.

The scenario’s where we need cross domain or multiple domains are,

  • We need summarized report on site stats of all domains
  • Business need a boosted or common report
  • Need a common goal analysis for all cross domains.

What you need to do is, customize your analytics cod as below,

<script type="text/javascript">

  var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'GOOGLE_ANALTICS_ID']);
 _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _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>

Also, Please select cross domain in Analytics admin. Please  update analytics code with following as above.

 _gaq.push(['_setDomainName', 'none']);

This tells to Analytics code that, even this request is belongs to same Analyical ID code. otherwise it will ignore as wrong analytical code.

But if you have only sub domain you try with following code

 _gaq.push(['_setDomainName', '*.EXAMPLE.COM']);
Subin George