Mobile app version of vmapp.org
Login or Join
Mendez628

: Google Analytics and Web Optimizer Code creating double site visits My website currently has a Google Asynchronous tracking code at the top of every page and the home page has an A/B test running

@Mendez628

Posted in: #GoogleAnalytics #GoogleWebsiteOptimizer

My website currently has a Google Asynchronous tracking code at the top of every page and the home page has an A/B test running on it. This is causing GA to add 2 visits for every 1 to the home page.

I have used Google's Web Optimizer to A/B test the home page against 2 other versions (all 3 have footer code). There is also a single goal page with footer code.

All of the codes are below, with only identifying info removed. My issue is that every person that visits my home page (www.example.com) is getting counted as 2 visits. This is obviously incorrect but I am not sure how to fix it. I have already tried a few different options outlined below but none have fully succeeded.

This is my GA tracking code:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_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);
})();
</script>


This is the Web Optimizer code below the GA Tracking code on example.com:
<script>
function utmx_section(){}function utmx(){}
(function(){var k='YYYYYYYYYY',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
</script><script>utmx("url",'A/B');</script>


My home page and the 2 variant pages have this in their footer:

<script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var gwoTracker=_gat._getTracker("UA-XXXXXXXXX-37");
gwoTracker._trackPageview("/YYYYYYYYYY/test");
}catch(err){}</script>


My goal page has this:

<script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var gwoTracker=_gat._getTracker("UA-XXXXXXXXX-37");
gwoTracker._trackPageview("/YYYYYYYYYY/goal");
}catch(err){}</script>


Here are my failed fixes so far:


Change the UA-XXXXXXXXX-37 to UA-XXXXXXXXX-1. This just makes my bounce rate for those pages go to 100%
Move the GA code in front of the Web Optimizer Code. This did not fix the issues but I left it because I believe it is correct.
Added gwoTracker=_gaq._setDomainName('.example.com'); between the ._getTracker and ._trackPageview of the 3 footers. This caused GA to work again and the Web Optimizer to quit working completely.


What is the correct way to do this?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez628

2 Comments

Sorted by latest first Latest Oldest Best

 

@RJPawlick198

I was able to solve this issue.

First you have to move the GA code in front of the Web Optimizer Code.

Then set your code like this:

<!-- Google Website Optimizer Conversion Script -->
<script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var gwoTracker=_gat._getTracker("UA-XXXXXXX-37");
gwoTracker._setDomainName(".example.com");
gwoTracker._trackPageview("/YYYYYYYYYY/goal");
}catch(err){}</script>
<!-- End of Google Website Optimizer Conversion Script -->


Do the same thing with your /test scripts.

It was tough for me to test this because it took so many days to get good results but this appears to work.

10% popularity Vote Up Vote Down


 

@Carla537

Have you asked on the Google supoprt forms or emailed Google themselves?

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme