Analytics
4.8K members online now
Discuss regaining access to Analytics accounts, restoring accounts, changing user access levels, and navigating the homepage
 
Guide Me
star_border
Reply

Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

My main web site is using www.site.com URL and I have a bunch of subdomains (blog.site.com, docs.site.com) that I want to track as the same Google Analytics property.

 

I use analytics.js which according to Google docs doesn't require any additional configuration to track subdomains:

 

ga('create', 'UA-XXXXX-Y', 'site.com');

 

My default URL in Google Analytics Property Settings is set as www.site.com (shown below), however I don't get any data from subdomains.

 

Do I have to change the default URL to site.com?

 

enter image description here

1 Expert replyverified_user

Re: Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

Top Contributor
# 2
Top Contributor

Hi :-)
the cookie domain in the tracking code needs to be set to auto:

Tracking user interactions across a top level domain and its subdomains happens automatically when using the recommended JavaScript snippet via the auto option for cookieDomain field.

ga('create', 'UA-XXXX-Y', 'auto');

 

If your main website is www.site.com then the website urls in Property and View settings should be entered as www.site.com
I also suggest also creating a new View and applying the following filter:

  • Filter Type: Custom filter > Advanced
  • Field A: Hostname Extract A: (.*)
  • Field B: Request URI Extract: (.*)
  • Output To: Request URI Constructor: $A1$B1

By default, Google Analytics only includes the page path and page name, not the domains name. For example, you might see your pages appear in the Site Content report like this:

  • /about/contactUs.html
  • /about/contactUs.html
  • /products/buy.html

Because the domain names aren’t listed, it might be hard to tell which domain each page belongs to.

The filter will tell Google Analytics to display domain names in your reports.




 

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

Top Contributor
# 3
Top Contributor

 

I'm seeing an issue with the tracking code on the main domain

I'm not seeing any tracking fire in Chrome js console at all, and Google Tag Assistant
gives the following information:

subdomain01.jpg  subdomain02.jpg

subdomain03.jpg

 

 

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

[ Edited ]
Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

On www.entriwise.com, we do use Cloudflare, whose Rocket Loader extracts scripts for additional cashing.  Google Analytics works fine with it but Google Tag Assistant fails to detected it.

 

I just turned Rocket Loader off and it's all green in Google Tag Assistant.

 

For docs.entriwise.com subdomain, we use GitBook which has a separate plugin for Google Analytics.  This might also be the reason why Google Tag Assistant doesn't detect it

Re: Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

Top Contributor
# 5
Top Contributor
I had no issue with tag assistant seeing the tracking on the subdomain
it also fired fine in chrome js console on the subdomain:

Initializing Google Analytics.

analytics_debug.js:9 Running command: ga("create", "UA-339047-25", {cookieDomain: "auto"})
analytics_debug.js:9 Creating new tracker: t0
analytics_debug.js:9 Auto cookieDomain found: "entriwise.com"
analytics_debug.js:9 Running command: ga("send", "pageview", "/02-config-quickbooks.html")
analytics_debug.js:9
Sent beacon:
v=1&_v=j41d&a=1031662345&t=pageview&_s=1&dl=http%3A%2F%2Fdocs.entriwise.com%2F02-config-quickbooks.html&dp=%2F02-config-quickbooks.html&ul=en-us&de=UTF-8&dt=Setting%20up%20QuickBooks%20Desktop%20%7C%20Getting%20Started&sd=24-bit&sr=1680x1050&vp=1680x243&je=0&fl=20.0%20r0&_u=AACAAEABI~&jid=&cid=712008548.1457707090&tid=UA-339047-25&z=2000316205


analytics_debug.js:9 _j1 (&jid)
analytics_debug.js:9 adSenseId (&a) 1031662345
analytics_debug.js:9 apiVersion (&v) 1
analytics_debug.js:9 clientId (&cid) 712008548.1457707090
analytics_debug.js:9 encoding (&de) UTF-8
analytics_debug.js:9 flashVersion (&fl) 20.0 r0
analytics_debug.js:9 hitType (&t) pageview
analytics_debug.js:9 javaEnabled (&je) 0
analytics_debug.js:9 language (&ul) en-us
analytics_debug.js:9 location (&dl) http://docs.entriwise.com/02-config-quickbooks.html
analytics_debug.js:9 page (&dp) /02-config-quickbooks.html
analytics_debug.js:9 screenColors (&sd) 24-bit
analytics_debug.js:9 screenResolution (&sr) 1680x1050
analytics_debug.js:9 title (&dt) Setting up QuickBooks Desktop | Getting Started
analytics_debug.js:9 trackingId (&tid) UA-339047-25
analytics_debug.js:9 viewportSize (&vp) 1680x243

anyhow.. if the main domain is www.site.com then the website url should be entered into the Property and View settings as www.site.com
To cross track across domain and subdomain then the cookie domain must be set to auto for all.
Not sure if the main domain being https will affect it, I dont have time to test a similar setup on my own server atm

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

Re: Google Analytics Property Settings Default URL for subdomain tracking with analytics.js

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
I made some adjustments and re-configured everything from scratch.

Hopefully it will help. I'll let you know.