Analytics
4.7K members online now
4.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Desktop and Mobile Traffic Integration

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've got the same content under two addresses - mobi.xxx.pl for mobile devices  and www.xxx.pl for desktop. I want to integrate statistics from both of them. If I set the same code as below, do I obtain what I want?

 

  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-23456789-1', 'xxx.pl');
  ga('send', 'pageview');

Desktop and Mobile Traffic Integration

[ Edited ]
Participant ✭ ✭ ✭
# 2
Participant ✭ ✭ ✭

Hi @Włodzimierz G

 

You're right, that's how it works. By setting cookieDomain to auto, or manually setting it to the topmost possible domain name (i.e. .xxl.pl), all subdomains can use the cookie.

 

You don't need to modify your default tracking code to be honest. If you have cookieDomain: 'auto' as the third parameter of the 'create' command everything will be fine as well:

 

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-23456789-1', 'auto');
  ga('send', 'pageview');

 

and

 

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-23456789-1', 'xxl.pl');
  ga('send', 'pageview');

 

 

Both ones work well. Hope this helps.

 

Cheers,

Taavi