AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
3K members online now
3K 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

multiple sub-domains + same code base

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Our website has three pages that use a sub-domain that is different then the rest of our site. 

 

So we have www.site.com and payments.site.com.  They use the SAME code base so I  can't change the analytic code for each domain as the instructions here say to do - https://support.google.com/analytics/answer/1034342?hl=en.

 

Can I simply have the following code which will cover my needs,  this code will run when a user is on  www.site.com and when they are on payments.site.com.

 

ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
  ga('require', 'linker');
  ga('linker:autoLink', ['www.site.com', 'payments.site.com'] );

 

 

2 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Rob M
November 2015

Re: multiple sub-domains + same code base

Top Contributor
# 2
Top Contributor
Hi Rob,

In Universal Analytics tracking users across subdomains does not require any additional configuration.

https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain?hl=en

So you'll be fine using the default tracking code, linker is not needed.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Rob M
November 2015

Re: multiple sub-domains + same code base

Top Contributor
# 2
Top Contributor
Hi Rob,

In Universal Analytics tracking users across subdomains does not require any additional configuration.

https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain?hl=en

So you'll be fine using the default tracking code, linker is not needed.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: multiple sub-domains + same code base

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Arnold,

Do you know, did the older analytics library ga.js not support tracking users across sub-domains?

Thanks,

Rob

Re: multiple sub-domains + same code base

Top Contributor
# 4
Top Contributor
Hi Rob,

sub-domain tracking has been possible with ga.js - you just would manually insert the setDomainname directive with plain domainname [1] in order to broaden the reach of the relevant first-party cookie to all hosts on that domain. That's done automatically now with Universal Analytics.

Christoph

[1] https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite

Re: multiple sub-domains + same code base

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi Christoph,

Thanks for this information.

Rob