We started the A/B experiments on our site. Homepage is the tracking site and it redirects to 3 other versions. Since the google analytics script (ga.js) is loaded just after the site is redirected, we are loosing the referrals data. The referral is always the original homepage.
I was not successful in searching for the clear and right solution.
How can I provide the referral to analytics?
Thanks in advance.
EDIT:
So I tried _setReferrerOverride method, but didn’t help.
This code is before the control script (the enter page for visitors, i’m lookinf for referrer here). I’m setting the cookie.
if($_COOKIE[abtestRef]) $_SERVER[HTTP_REFERER] = $_COOKIE[abtestRef];
if($_SERVER[REQUEST_URI]=='/'):
setcookie('abtestRef',$_SERVER[HTTP_REFERER],time()+300,'/','cloudee.eu');
<!-- Google Website Optimizer Control Script -->
<script ....
And here is the tracking script on page which the control script redirects to. So I’m setting referrer from cookie here … but there is no change in GA, so probably I’m doing something wrong.
<!-- Google Website Optimizer Tracking Script -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['gwo._setAccount', 'UA-27591323-1']);
_gaq.push(['_setReferrerOverride','<?=$_COOKIE[abtestRef]?>']);
_gaq.push(['gwo._trackPageview', '/2713975509/test']);
(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>
Crayon is right. Here’s an example snippet that works on my site: