Setting up google analytics for different domains - google-analytics

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.

Related

Can you implement google analytics with no domain binding?

We have a web service which is installed on different stations. Each has a different ip and domain. we want all of them to report to the same suite.
Can this be done?
The JavaScript tracker for Google Analytics can be used if you allow calls to the Google Servers, if you allow your clients to execute JS and either can set cookies or provide a client id in some other way (must not be personally identifiable data).
If you cannot use Javascript then you could still collect data via the measurement protocol, although this might require substantial development effort.
The domain setting in the Google Analytics interface does not affect data collection, it is used in the (soon to be removed) in-page analytics feature and as base url for the "open document" feature in the behavior reports.
Google Analytics does not collect by domain, but by property ID (UA-XXXXXXX-X), else cross-domain tracking would not be possible (it is actually a documented feature).
Cross domain tracking would be important if somebody could hop from one of your stations/domains to the other and you wanted this to be tracked as a single session. This does not seem to be your use case.
The only pitfall is that the reports display page paths, not full URIs. So if you have similar paths on all your stations the metrics for the page paths will be lumped together unless you do a breakdown by hostname. A common workaround is to add a filter to your data view that prepends the hostname to the path, or to provide custom paths in the first place.
But basically this is not a problem. If you do not need cross domain tracking you'll be okay if you dump the same tracking code in all your sites.

multiple domains, how to use the same GA property

I am trying to implement cross domain tracking for two of my domains. While reading the Google Docs on the matter, I got confused by the following paragraph toward the end of the article (bold text):
Both domains need to use the same GA property in order for cross-domain tracking to work correctly. If the sites use different properties, no session information will be shared and cross-domain tracking will not work.
Cross-domain tracking supports multiple trackers, but be aware that they will all share the same Client ID used by the linker.
The scenario I have is:
example.com --> the first domain used to promote my product
domain2.com --> the second domain which is used for secure checkout.
When creating a properly in Analytics, I need to enter the default url. How can I set this up so that I can then use the same property code for both domains?
Can't find any other related questions or articles on this, so I feel I am missing something simple.
It means that you have to use the same UA ID on both sites so that the GA property can collect the data on those 2 sites. You should use GTM to do cross domain tracking since it is much easier to set-up.
I recommend following the instructions here http://www.lunametrics.com/blog/2015/06/16/cross-domain-tracking-with-google-tag-manager/

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.

How does google-analytics guarantees that the tracking record is coming from the real site

When you sign up to google analytics it instructs you to use a javascript snippet on every page you want to track. This code includes an API key, which is visible to everyone who views your source code.
How does it guarantees that the request is coming from the real site, and not from a third-party who wants to mess with your statistics? Does it check the HTTP Referer header? Even that is not safe, as it can be forged.
GA doesn't (to the best of my knowledge) attempt to verify that the site ID (the UA-XXXXX-XX code) matches a domain specified in the GA setup - I think this is a good thing, as you can track a bunch of related sites as though they were a single site (think single-product minisites, for example). However, this does leave the GA profile open to accidental or malicious use of the UA code on other unrelated sites.
The easiest way to fix this is to add a filter onto the GA profile which restricts reported data to a specified referrer hostname set. This will clean out the accidental typo problem, but malicious types would be able to work around this if they were really interested (but they'd be more likely to grief your PPC campaigns instead).

Does google analytics combine naked domains with the www subdomain?

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.

Resources