Google Analytics Sub Sub domain visit logged as homepage visit - javascript

I currently have my Google Analytics setup to monitor each sepearate subdomain on my site.
I have over 180 subdomains each with their own Google Analytics profile.
These subdomains have their own subdomains and the problem is that it keeps recording the visits to sub sub domains as visits to the homepage "/"
I know this because I checked it in "Real Time > Overview"
Domain structure
subdomain: test.domain.com
subsubdomain: info.test.domain.com
I have enabled sub sub domain tracking in each profile but it doesn't seem to affect the results!
My Google analytics js is as follows
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX']);
_gaq.push(['_setDomainName', '.test.domain.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);
})();
</script>
Any ideas?

Related

Multiple domain tracking with an iframe - landing page showing up as iframe source in GA

So we have website A www.domaina.com and within this website there is an iframe that is shown on all pages, which has source from website B www.domainb.com.
I have setup cross domain tracking using the following code, and if test in GA real time going between the 2 sites, it is correctly showing there is only 1 visitor always. But the landing page (and active page if viewing in Real time) is showing up as the iframe source. I can see this is because using GA debugger, there are multiple tracking beacons being sent out as soon as you land on the home page, and the last one is from the iframe, showing the referring URL being www.domaina.com and the page being domainb.com. THis hence is causing self referrals to show up..
here is the code, but i have no idea how to fix! Im thinking maybe should all the _setDomainName be set to the domain's? I have read conflicting advice on this.
many thanks
GA code domain A
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7338871-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
GA code domain B
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7338871-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
iframe script domain A
<script type="text/javascript">
var iframeLink = "domainb.com";
_gaq.push(function() {
var pageTracker = _gat._getTrackerByName();
iframeLink = pageTracker._getLinkerUrl(iframeLink);
document.getElementById("myIFrame").src = iframeLink;
});
</script>

Google Analytics Not tracking data correctly IP-address issue?

I have developed a small site for a client and the site has been placed inside a <iframe> at the clients site. The GA-script I'm using looks like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-XXXXXXXX-2'], //My company's GA-account
['_trackPageview'],
['b._setAccount', 'UA-XXXXXXXX-1'], // Test GA-account
['b._trackPageview'],
['th._setAccount', 'UA-XXXXXXX-3'],
['th._setDomainName', '.clientdomain.se'], // Client GA-account
['th._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);
})();
</script>
</head>
As you can see I report the GA pageviews to the client as well. The GA script is tracking visitors and pageviews at both ends. But the problem is that on my clients side the visitor-count is more than double what they are on my end (20 000 vs 5 000). At first I thought that it was being duplicated at some point but when I checked my Crazy-Egg account I saw that it had tracked over 10 000 visits and then stopped tracking because that was my limit on the account.
The page my site is on is on a IP-address (http://XXX.XXX.XX.X/campaign/) and not on a "valid url". Could that be an issue why some of the visitors isn't beeing tracked?
Thanks in advance

How to have a single google analytics account for multiple domains

I have a Google analytic account which I'm using to track analytic of the domain a.com. Now I want to add b.com statistics to the same account. Given that they don't allow free Google analytic account creation anymore.
What I have done is according to this article and this. Both are the same.
Code are below here.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35089154-8']);
_gaq.push(['_setDomainName', 'www.a.com']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
In the b.com domain I have below code
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-35089154-8']);
_gaq.push(['_setDomainName', 'www.b.com']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
But statics of b.com is not show in Google analytic account? How can I fix this?
Create a new property in the account (which will give you a new Account ID) and use that for domain b.
What is described in the article is cross domain tracking - that is needed only when you want to track two different domains so that they appear as one domain in your account (so you can for example track movements between the domains without losing campaign information).
#Eike's answer is correct. Below are the steps how it should be done.
https://support.google.com/analytics/answer/1042508?hl=en

Two google analytics accounts per page [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
google analytics - multiple trackers on one page (cookie conflict)
I've searched around the internet about this question, but cant find the answer I am looking for.
I've developed a blog, with some special features. Each user get their own subdomain when they register.
Everything is free, but with ads. And I currently use google analytics to track the total number of visitors and pageviews.
I've developed a small counter so that each user can se how many visitors and pageviews they have, but for more detailed informatino they need to use their own "google analytics", or what ever they want to use.
So. The code I use now:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx1-1']);
_gaq.push(['_setDomainName', 'sub.domain.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);
})();
</script>
I dont know what type of analytics service each user will use, I let them insert their own code within the HEAD.
So, IF they use google analytics, will our two accounts at google analytics get the correct number of visitors? The code will then be:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx1-1']);
_gaq.push(['_setDomainName', 'sub.domain.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);
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx2-1']);
_gaq.push(['_setDomainName', 'sub.domain.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);
})();
</script>
Or do I have to do it like:
_gaq.push(
['_setAccount', 'UA-XXXXXXXX-1'],
['_trackPageview'],
['b._setAccount', 'UA-XXXXXXXX-2'],
['b._trackPageview']
);
Where both trackers are within the same . ??
Thanks!
This is an example and it works. I have the same code on mine.
_gaq.push(
['_setAccount', 'UA-XXXXX-1'],
['_trackPageview'],
['b._setAccount', 'UA-XXXXX-2'],
['b._trackPageview']
);

Cross Domain Google Analytics

I'm aware there is a fair amount out there about this sort of thing, but I can't get mine working. I'm only worried about cross domain and not about sub domain.
I have 2 sites, www.siteA.com and www.siteB.org for example.
SiteA has a link to my registration page on SiteB.
On SiteA I have the following script (On my layoutpage/master):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '##AnalyticsIDA##']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
On SiteB I have the following script (On my layoutpage/master):
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '##AnalyticsIDA##']);
_gaq.push(['_setAllowLinker', true]);
_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);
})();
</script>
I have a link on SiteA
testing
This takes me to www.siteB.org with all the correct parameters (same as my SiteA cookie values), but SiteB's cookies have different values to SiteA.
EDIT
Futhermore, I've also tried using _gaq.push(['_setDomainName', 'siteA.com']); and _gaq.push(['_setDomainName', 'siteB.com']); but I still get new cookies on siteB
Have you tried using _setDomainName in your GA code? From the Cross Domain docs:
(_setDomainName) Use this when you want to treat top- and sub-domains as one entity and track in the same profile. Also use this when you want to track across multiple top-level domains AND their sub-domains. In this case, you will need to using linking between the top-level domains, but not between the top-level domains and their sub-domains.
In your case, on SiteA
_gaq.push(['_setAccount', '##AnalyticsIDA##']);
_gaq.push(['_setDomainName', 'siteA.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
and on SiteB
_gaq.push(['_setAccount', '##AnalyticsIDA##']);
_gaq.push(['_setDomainName', 'siteB.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
Try changing the onClick to:
onclick="_gaq.push(['_link', '.siteB.org']); return false;"

Categories

Resources