Reputation: 4299
My profiles on google analytics is http://example.com (don't have www ). And this script on my site :
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxx-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
Google Analytics will count view from subdomain.example.com ?
And a other question i want free google analytics 's cookies from static.example.com . I tried put _gaq.push(['_setDomainName', 'example.com']);
But still see cookies on images from static.example.com on firebug.
Upvotes: 0
Views: 333
Reputation: 867
The truth of the matter is, your GA account will "track pageviews" on any page that has your tracker (with your GA account#) in it (unless you have special filters set up). Now, it won't share referrer information across domains/subdomains unless it's set up to do so, but technically someone could place your tracker code on their site to inflate your site stats.
At the same time, you'd be able to see the content(page URLs) that have that code on it. I don't know why anyone would want to do this, but it is hypothetically possible
Upvotes: 0
Reputation: 22832
If you have subdomains you should use the following code on every one of them:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxx-2']);
_gaq.push(['_setDomainName', '.example.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
But note that this will cause the cookies to be sent to the static subdomain as well. The best way to isolate the static domain is to have it as a different domain, not as a different subdomain. If you store the GA cookies on the full domain instead of the top domain you will clear the static domain but it will be much harder to correctly setup GA.
Upvotes: 2