Google Analytics - one real time monitoring for more domains - google-analytics

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.

Related

I need to measure traffic from root domain to subdomain as Refferal - GA4

I need help with the following case. My client has a website where the catalog and product informations is on the main domain https://fixed.zone from the product cards links to the eshop which is on the subdomain https://obchod.fixed.zone
I need the person who clicks through from the root domain to the eshop to be a referral in GA4. It now appears as Direct.
Can anyone advise me how to achieve this? The GA4 code is only on the eshop. It is not on the catalog page. I didn't set up the analytics on the main domain but someone else did. However, I can also intervene in the website on the root domain
I tried to google the solution but it seems to be kind of rare set up
Referral attribution is something you typically don't touch. It's something Google comes up with on its own. If this dimension doesn't do the trick, you just use a different dimension, like the actual referrer, or a segment where you select sessions that have both hostnames.
Still, there is a way to trick GA. A few ways, actually. For example, you could have logic in GTM that would run on subdomain that would check user's document.referrer on every hit before sending pageview. Once the referrer is from the TLD, you override the referrer dimension in the call and replace the TLD in it to something else, that way those hits will look like they came from a different TLD and will be treated as referral traffic.
Or you could issue an event every time a user navigates to the subdomain, so you could just look at those events.
Same issue here. Managing a GTM container and GA4 property for a subdomain that is separate from main domain. By default in GA4, it appears as though the main domain traffic is lumped in with direct traffic rather than a referral. We need isolated referral data from main domain to subdomain in GA4. Lumping the traffic into direct will not work for us. The UA property for the same subdomain lists the traffic from the main domain as a referral.
I created a GTM GA4 event tag for traffic tracking.
parameter name: referrer_URL
value: {{HTTP Referrer variable with component full URL}}
trigger: Page View - trigger fires on: {{HTTP Referrer variable with component full URL}} does not contain "my.subdomain" (to exclude self-referrals)
created custom dimensions in GA4 for new parameter "referrer_URL" so it will be visible in reports
After approx 24hrs my new custom dimension started showing up in reports.
In GA4 reports->Acquisition->Traffic acquisition click the "+" next to first column header of "session default channel group" and select custom->"your.custom.dimension" (or search for your custom dimension). Default channel groups should be broken down further into your custom dimension urls.

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.

Do webservers have to be publicly accessible for Google Universal Analytics to work?

I am using the "Bi-directional cross-domain tracking" script from Google to track visitors on a secondairy domain.
This is the script I am using:
ga('create', 'UA-xxxxxx-1', 'auto', { 'allowLinker': true });
ga('require', 'linker');
ga('linker:autoLink', ['main.com', 'secondary.com']);
ga('send', 'pageview', window.location.pathname);
The script can be found here:
Analyics.js Linker
I also made sure both domains were included in the "Referral exclusion list".
I have installed Google Tag Assistant (a Chrome extension), and it works like it's supposed to. I get a green icon, and also the message that 1 request is made. But I don't see any hits in Google Analytics.
I called with Google helpdesk, and only then I realised that 'secondary.com' is a server (used for testing) accessible only on our internal network.
Is that the reason why there are no results in Google Analytics?
Update
When we put our code in production we did get results in Google Analytics.
But that does not automatically mean that a server should be publicly accessible for the code to work, because maybe the problem was that the test server was on a sub-domain.
To make things clear we have:
companyname.nl (main.com in code)
mycompanyname.nl (secondary.com in code)
test.companyname.nl (the server that is not accessible from the outside)
According to the documentation:
Automatic cookie domain configuration sets the _ga cookie on the highest level domain it can.
So I Assumed test subdomain would work too.
I will unaccept the answer from #eike-pierstorff since it's unclear what's really going on.
To answer your question quite literally, no, webservers must not be publicly accessible for Google Universal Analytics to work. The Google Analytics web tracking code does not run on the webserver, in runs in the browser (or other client program). So if the client can access both the internal network and the public internet this should work (
This is more or less the end of the answer, I'll add a few more things in the hope it will help.
For the Google tracking code to work it must be able to set a cookie (or configured with 'storage': 'none' and have a client id set by your application), so you'd have to check if your internal url is actually a fully qualified domain name (so js cookies can be set; I'm not sure if secondary.com is just an example or if this is the actual format used in the internal domain name). But even then you should at least see traffic from the public url. The fact that you do not (plus you receive a green light from Tag Assistant) suggests that the problem is not at the collection end.
Did you by chance set up any filters that might affect the way data is collected ? In particular include filters are tricky (since they delete all data that doesn't match a pattern, so if the pattern is wrong they delete everything). If you haven't done it yet create a view without any filters to always have a backup of your data when a filter is misconfigured.
Since you mentioned these in the posts, neither the referral exclusion list nor the linker are likely to have anything to do with your problem; the first maintains the original channel attribution when people switch between domains, the second adds a parameter to links and form actions that allows the other domain to pick up the client id and thus continue the session. The worst that could happen is that cross domain tracking does not work, but sessions on both domains would still be (separately) tracked.

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).

google analytics for subdomains - good practice

Say, I've a website www.website.com, and we are maintaining a subdomain sub.website.com for blogging. Now my question, what is a good practice of having google analytics for both domains, same tracking for both or individually? and why?
Regards
Generally speaking, the best practice is to keep subdomains of the same domain on the same account. (The exception is if the subdomains are completely unrelated sites.)
It's important, though, to adjust your Google Analytics snippet to set its cookies on the root domain, so that users who traffic between subdomains are tracked as a single visit, instead of multiple visits.
You can accomplish that by putting the following call before your _trackPageview call:
_gaq.push(['_setDomainName', 'example.com']);
Then, on the account management side, you can setup filters for individual subdomains (using Hostname filtering) so that you can get a snapshot of both the combined traffic and the individual subdomains.
EDIT: Removed the leading period on the URL. This will make it compatible with past traffic that doesn't have a setDomainName call.
[Expanded from comment above, as ran out of chars]
The setDomainName command as noted above will work, but if you're using an existing GA setup, using setDomainName = "example.com" (no leading dot) will retain existing GA user IDs, so the new-user metrics will still be valid (GA hashes the domainname into the user ID, but strips "www.example.com" down to "example.com" before hashing. However ".example.com" will hash to a different value, and the user IDs for returning users will not match their original IDs.
If you're starting a fresh site, use ".example.com" (and it's sometimes required for sites with deep FQDN), and don't forget to check what's being sent back to the GA with Firebug.
I think you can get away with just one domain. I never tried to use subdomains, but even with one domain, Google analytics gives you a good breakdown and visibility of the stats. Plus the urls of the pages are different and you can differentiate on that even if you track a single domain. Plus you will avoid domain-clutter.

Resources