Prusak.com

Serving up my thoughts since 2004

Google Website Optimizer and Referer Data

Google Website Optimizer A/B experiments use JavaScript to redirect the visitor to a test pages.

When a visitor is redirected with JavaScript, you loose the original HTTP referer data (the page that did the redirecting now becomes the HTTP referer)

Here’s an example:
Lets say the original page is page.html and we have a test page page_1.html

Before the test, page.html got 1,000 visitors a day coming from Google searches (organic traffic).

So we have Google -> page.html

Now that the test is running you’ll have 500 visitors to page.html:
Google -> page.html

and 500 to page_1.html
Google -> page.html (JavaScript redirect) -> page_1.html

If the web analytics code is after the redirect on page.html (which is what Google tells you to do) then data based on the HTTP referer will be incorrect (traffic source, keywords, etc).

If you REALLY want to capture the HTTP referer related data you can put the analytics code before the redirect. You’ll now be able to capture the original HTTP referer data, but you’ve also just inflated the page views.

I’ve solved this issue for some in-house code that uses the referer data by simply storing the HTTP referer value in a cookie right before the redirect, and then using the cookie value on the test page.

Unfortunately Google Analytics doesn’t do this.

Here’s a feature request for the Google Analytics team:

Add a way pass in the HTTP refer data manually.

I’m sure Website Optimizer isn’t the only tool using JavaScript redirects from a landing page.

1 Comment

  1. Hi ophir,

    Thank you very much for sharing your knowledge with the community. I don’t know how I didn’t come across your articles before. Shame on me 🙂
    Well, now I know about your site thanks to a member of our webmaster forum, who posted the link.

    Keep up the good work,
    Jordi

Leave a Reply to Jordi Cancel reply

Your email address will not be published.

*

© 2019 Prusak.com

Theme by Anders NorenUp ↑