Analytics.js track webapp multiple domains - google-analytics

We have a webapplication hosted on our servers.
Some customers use our predefined (sub)domains and some other customers use their own domain (paid users).
As I want to track total usage of all established webapps I'd like to use the same tracking code on all domains?
The customers can add their own tracking code too (I've already figured out how to do this).
So is it possible to do it like this?
sub1.domain.com -> UA-XXXXXXX-1
sub2.domain.com -> UA-XXXXXXX-1
customer3.com -> UA-XXXXXXX-1
customer4.com -> UA-XXXXXXX-1

Here are the best tutorial for it
http://www.ericmobley.net/guide-to-tracking-multiple-subdomains-in-google-analytics/
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#multipleDomains
The trick is the cookies domain property:
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'example.com'});
ga('create', 'UA-XXXX-Y', auto);
most of the time you setup as auto. Check the doc for more info about the cookieDomain.
To Tracking Across a Domain and Its Subdomains
As mentioned above, a default setup of Google Analytics is designed to
track content and visitor data for a single domain, such as
www.example.com. This means that even if you manage both a domain and
a sub-domain, you must make modifications to the tracking code in
order to share visitor data across both domains.
Display Subdomains In Your Analytics Data using custom filters and Set Up A View For Each Subdomain (Optional).

Related

How can I test/verify if users are tracked across subdomains n Google Analytics?

I have my UA setup across three sites www.aerserv.com, platform.aerserv.com, and support.aerserv.com. I want to be sure I'm tracking users across the domains properly so the analytics don't see each visit from one user as a "new user".
Is there a way to verify that I've setup my tracking correctly and Google isn't mis counting visitors?
Subdomain tracking is done out of the box in GA, and the only thing you need to make sure is that the cookie domain setting is set to 'auto', and that the referral exclusion list includes the main domain. Once you have those set, and if all pages across all applicable subdomains are tagged, then you should not have any issues. If you need to check, then you can look at the client ID (cid) for each pageview hit from one subdomain to the next. The client ID should be the same.

Google Analytics - one real time monitoring for more domains

Is it possible to set up google analytics for more domains with one real time monitoring.
I have one main domain and 100 subdomains.
Example:
main.com
sub1.main.com
sub2.main.com
sub3.main.com
...
I want to track visitors in one google account with one real time monitoring. How can I do that?
Thanks
You do that by adding the same Google Analytics tracking code to multiple domains. The base domain from the Property/View settings are not relevant for data collection, so the same code will run on arbitrary domains.
(edited) Even less of a problem with subdomains. The default setting for the cookie domain is "auto", so the same cookie will be used for all subdomains. If you do not want this (e.g. if you want a user who switches between subdomains to be considered a new user) then you would need to set the cookie domain dynamically to the respective subdomain:
ga('create', 'UA-XXXXX-Y', {
'cookieDomain': document.location.hostname
});
However by default the reports displays page paths, so you might not be able to tell from which domain a request originated; to do that you need to add a filter to your view that adds the hostname to the page path. An older but still working tutorial is e.g. here.
Naturally everything that shows up in real time monitoring will later become part of the permanent reports.

Track Google Analytics conversions from domain to subdomain

I'd like to track the conversion rate of my site using Google Analytics across multiple subdomains.
The scenario:
A: www.site.com <- where sessions begin.
B: app.site.com <- where sign up starts.
A conversion for www.site.com is a session moving to app.site.com.
Currently conversions on site.com look like drop offs.
I've already set up two views to separate A and B.
Side note: B is ignoring referrals from A.
I've set up conversion tracking on B.
My question is: how do I track the conversion of site.com sessions travelling to app.site.com using Google's Universal Analytics?
Are you using analytics.js? If so this happens automatically.
The main way people screw it up is by not setting cookieDomain to 'auto', which, if you use the default snippet, should already be the case:
ga('create', 'UA-XXXX-Y', 'auto');
Without seeing your implementation, it's impossible to know why yours isn't working, but just know this does work out of the box with no special configuration.
According to the developer site, Universal Analytics does not require further customisation to the _ga cookie. Use the default analytics.js code snippet to track between your domain and subdomain. Make sure to use the javascript code in both websites.
If you require that a visit to app.site.com is considered a conversion in site.com, then you need to attach an event to the link in site.com that points to the app.site.com and setup a goal for that event.
Have a read to this article, hope that helps.
Cheers

Cross Domain Tracking - see original source in Real-Time Reports

I have set up Cross Domain Tracking for two different domains with two different GTM containers. I added both domains, a.com and b.com in the Auto Link Domains in both Universal Analytics tags, set Allow Linker for both to true and set Cookie Domain to auto. However, when I'm surfing from Facebook to website a.com and click through to b.com I see a.com / referral as a traffic source in the real-time reports in Google Analytics. This should be Facebook in this case right? Does someone have a method to debug this issue?
Thanks!
Use Referral Exclusion List in Property Tracking info. This will exclude traffic from a.com from referrals.
Possibly you are not a Google Analytics Premium member?
The second thought is maybe you are using two Google Analytics properties (one for each domain) and not using one property for both domains?
To be able to utilize the cross domain function you must have one Google Analytics property associated to all domains. You might have the results of funny "referral sources" because you are using two different properties (UA-1111111-1 and UA-2222222-2.
Read more about multiple cross domains
Or for specific cross domain info (notice the part about "UA PROPERTIES)
Let me know if that is the issue, and what your next strategy might be.

Can I use Google Tag Manager to collect analytics from mulitple domains?

The set-up:
1 site, 2 domains: = mysite.com and mysite.co.uk
These 2 domains use DNS to point to the same site (IP).
There is 1 snippet of Google Tag Manager (GTM) code just after the opening <body> tag of the site (every page).
In the GTM container, I have added both domains on the "Container Settings" page.
There is one Google Analytics (GA) account which only contains the .co.uk domain. (An analytics account can only contain 1 domain.)
A tag has been set up in GTM with the type of Google Analytics and it has the UA code from the 1 GA account added.
A rule has been added to fire on all pages
Now, I don't care whether someone visits via .com or .co.uk, but I want to capture combined analytics for both. My questions is, with the way I've set things up using GTM, will GA save data for both domains ie mysite.com and mysite.co.uk, or do I need to set things up another way to achieve this? Ideally, I don't want to go down the forwarding route i.e. forward all traffic from .com to .co.uk.
First a bit of pedantry: Google Tag Manager cannot even collect informatiom from a single domain (it's not a tracking tool). And while you can only enter one domain in Google Analytics that domain setting serves no actual purpose; a Google Analytics account can track multiple domains in different "properties" (porperties are sections in an account that each have a unique id) or in a single property via cross domain tracking. Cross Domain tracking is used if you want to treat multiple domains as a single presence on the web (i.e. if you have a website and a shop with different domains, they still belong together).
Now, the way you have set things up data will be collected from both domains. There are at least two caveats:
1) If users can switch between domains inside a session (go from .com to .co.uk and back) their sessions will be interrupted and Google Analytics will register multiple visitors (that's because users are tracked via cookies which are domain specific). To avoid that you'd need to set up cross domain tracking (and how you would do that depends on if you are using Universal Analytics or asynchronous code. Look at your tracking code, if it contains a line that starts "ga("send"...." your are using analytics. If it contains lines that start with _gaq.push you use asynchronous code).
Cross domain tracking documentation for UNiversal Analytics (analytics.js)
Cross domain tracking for asynchronous code (ga.js)
2) By default Google Analytics tracks only the path, not the domain. If pages on both domains have the same path they will be displayed in aggregated form in the reports, that is if you have an index.php on both pages the visits for both will be added up. Maybe that's just fine with you, if they show the same content in any case. Else you'd either have to use "hostname" as a second dimension (which is not a sticky setting, you would need to re-apply that every time you switch to another report), or you create a filter on your view that includes the hostname in the reports.
Those caveats are relevant because data will show up in any case and will look perfectly okay even if it's not (even if you decide that those two things do not bother you you need to take them into account when you interpret the data).

Resources