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
Related
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>
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
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?
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']
);
I have a domain, lets call it myhost.com and i have a script addGAcode.js on myhost.com. The code contains function includeGA() that calls the standard GA code for a account set for my client domain. It looks like this:
function includeGA() {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-432432432-43']);
_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); })();
}
includeGA();
Lets call this domain groceryinbelfast.com.
Now i add to meta of groceryofbelfast script tag to include the myhost.com/addGAcode.js. Unfortunately GA does not work. The GA code is loaded properly but i suppose because it's located on other domain that the domain groceryofbelfast it cannot set cookies on groceryofbelfast domain that are necessary for statistics to work.
The point of my concept is to have GA script on my server so that when Google will change something in it or i will want to make some adjustments to it i dont need to call every time the webmaster of my client to make appropriate changes.
Any ideas?
Your includeGA() function probably won't work because _gaq needs to be declared as a global variable, not a local variable inside your includeGA() function.
You can fix that particular issue by changing to this:
function includeGA() {
window._gaq = window._gaq || [];
_gaq.push(['_setAccount', 'UA-432432432-43']);
_gaq.push(['_trackPageview']);
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);
}