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.
Related
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.
I have a web site that several parts are hosted in a different name server. but they are practically the sub parts of the same sites. (i know it's badly designed)
Currently, i get analytics data for each domain. but what i don't like about that is when you are jumping to the other domain, it marks as a drop off. Is there anyway that i could setup analytics in such a way that it treats both domains as a single website?
You are looking for cross domain tracking. Google has quite extensive documentation on this. Follow the instructions for Cross Domain Autolinking, manual linking is usually unnecessary and somewhat error prone.
The basic idea is that, since the cookie that stores the client id is domain specific, the id that identifies users must be carried over in some way from one domain to another. This is done by putting it in the url, in a parameter named "ga". If the other domain is configured for cross domain tracking it will take the parameter from the url instead of generating it's own client id. When GA processes the data on the serverside it will recognize that the calls from the different domains (but the same client id) belong to the same session.
Google Analytics (via the autolinking plugin) provides functions that automatically "decorate" links and form, i.e. they add the ga parameter to the links that point to the linked domain, or to form actions. This works well with plain links and forms, but might not always work with javascript callbacks on the links that redirect instead of just following the link.
We have a Universal Analytics implementation that has multiple trackers in use across different sections of a site. There is one 'global' tracker which resides on all pages of the site, and then a number of individual trackers on separate Web Properties which are for versions of the site in other languages, which are hosted in subdirectories. i.e.:
www.example.com - has global tracker
www.example.com/fr - has global and /fr trackers
www.example.com/es - has global and /es trackers
and so on...
Each of these /xx subdirectory trackers has its own _ga cookie on a separate path matching the language, so the tracker for .com/es has its cookies on the path '/es' for example.
So with that setup in place we were expecting to see valid self-referral traffic from visitors moving from one subdirectory to another, or from the .com root site into one of these language specific sites. However, we're only seeing these visitors as Direct traffic.
We have removed the root domain from the Referral Exclusion List in the tracking settings for each of these properties, but that doesn't appear to have affected anything at all.
We do want to see traffic moving these directories though, does anyone know how we can get these "legitimate" self-referrals appearing again, or does Universal Analytics cut them out by default? Would I be able to use filters (using the full referral URL field value) or channel groupings to swap this traffic into Referrals or is there another/better way?
Any help would be greatly appreciated! :-)
Cheers.
It may happen that those visitors have been already marked as direct traffic, so they are not taken as referrals. Your change may only affect to NEW visitors.
We have a dozen or so sites, as well as the occasional subdomains so:
example.com
example.co.uk
us.example.com
etc
We have been using separate GA codes for each site. This works fine, but it means that adding a new site means getting a new code and we can't tell overall stats (e.g. how many people have visited all sites etc). If we went the one code route and set up separate profiles for each domain/subdomain:
1) Should we use _setDomainName("none") or _setDomainName("www.example.com") and _setDomainName("www.example.co.uk") etc
2) Will each domain profile treat the other domains as separate (e.g. will we tell on example.co.uk how many people visited from example.com and completed goals etc)
3) Are there any disadvantages to this method.
This post from the Google Analytics blog details how to set up a GA account for each site, and an overall 'rollup' account which sits on top - this will let you give separate GA admin control for each site, where you can dig deep into each site's account, and show cross-site referrals, and the rollup will give overall numbers (but I don't think it's going to report on unique visitors across the collection of sites).
http://analytics.blogspot.com/2009/09/advanced-structure-your-account-with.html
I have google analytics installed for my own domain, http://mydomain.com. Will a user that enters http://www.mydomain.com be counted by the analytics script too?
To me it seems logical that it would, since it is so common to have the naked domain address be the same site as the www-prefixed one, but the analytics documentation doesn't state it explicitly.
Yes, users will be tracked, but the same visitor coming from www.datalookups.com and datalookups.com will be counted as two different visitors. GA uses cookies to store session information on visitors, and since www.datalookups.com and datalookups.com are different hosts, different cookies belong to them. To get over this issue, I suggest to set up a proper HTTP redirection that brings permanently either user from www.datalookups.com to datalookups.com or vice versa—it's a matter of taste. (Not to mention that this method balks search engine crawlers to index your web content twice.)
For the sake of completeness, there is a way to tell Google Analytics to share session information between to different hosts with the pageTracker._setDomainName function, but that is not the right answer for the current situation.
Yes, that has been my experience.