I just read a post by ShoreTel who suggests using initData without the trackPageview call. This will indeed set the GA cookies with the correct initial referrer value and not mess up pageview numbers.
and change it to this:
Both solutions should work fine!
November 5, 2008 at 9:01 am
The solution here is awesome. I will definitely be using this on the site’s I’m working on.
On another note I had a quick question on setting up an A/B test on a WordPress website. The issue I’m having is that Website Optimizer wants the initial control script above the tag. While adding the control script on the page template works it also adds the script to everyone of my pages. Most browsers don’t mind but Chrome gets trapped in an infinite loop.
I searched everywhere and no one has a solution on how to add Website Optimizer code to a WordPress website for an A/B test. The only thing available is an extension that allows for multivariate testing on headlines and images.
December 17, 2008 at 2:43 pm
I’m not sure I’m following – does this process overwrite the ‘last referrer’? How do you then use the ‘initial referrer’ data within GA?
January 8, 2009 at 12:13 am
The initData function is no longer included in the default GATC and may vanish from ga.js altogether. I’d recommend setting the account to some bogus id, then running pageTracker:
var pageTracker = _gat._getTracker(“UA-0-0”);
January 8, 2009 at 5:39 pm
Using a bogus ID sounds like a good idea (I’ll trust you it works).
I wouldn’t be worried though about Google removing the initData function anytime soon (or at all). Google is pretty good about keeping backwards compatibility. Think of all of the existing installations that would break if they were to do so.
March 20, 2009 at 12:45 pm
did you see the recent discussion thread?
Two gents started arguing each of theirs was the best solution, and I am confused.
What would you recommend given your own experience on the matter?
May 14, 2009 at 5:12 pm
Is the change you suggest above here the ONLY change to be made to the page? Or, does the above need to be combined with any of the changes suggested in your previous solution? ShoreTel suggests also to add another instance of the full GA tracking code at the bottom of the page, this instance including the page tracker as well? I am totally lost… help ! Many thanks for your assistance !
March 1, 2010 at 4:03 pm
You have to check up these Google Analytics tips
October 13, 2010 at 9:01 am
Ehi evrybody, but this is the old code, but what are talking about new asynchronous code?
It is the same thing? Or what??
Thanks a lot.
April 2, 2012 at 11:43 am
I am having the same issue. I am running an A/B and it appears that the B page has a very high direct traffic. Now if we are using the latest asynchronous google analytics, can we run this on the control page before the transfer:
var _gaq = _gaq || ;
Next question is why does it go into the A (landing page). Shouldn’t it be initialized in the B page where the referrer is not set? Or is it that by calling this trackpageview on the A page, it doesn’t wipe out the referrer but rather passes it to the B page? Your help would be much appreciated.