How to get Google Website Optimizer and Joomla to work together

Finally, I mustered up the courage and took the time to write my first post. Do read, enjoy, comment, curse to your heart’s desire. If I like the experience, maybe I’ll write even more … you have been warned!

Ever wanted your website to be more profitable?

Nowadays, websites for hobbyists, are well, just for fun; everything else is serious business, so undoubtedly turning a profit is first and foremost. How can you know if you’re not leaving money on the table? One sure way is to tweak your website to get more revenue from each visitor. Making simple changes can lead to large increase in conversion rates and profits.

Google’s Website Optimizer (GWO) probably needs no introduction by now, but let’s say that it’s a tool which allows you to test changes to your website scientifically in a controlled environment, before fully committing them, thus saving you from the painful mistakes of just following a gut feeling. I know from firsthand experience that can hurt, bad.

I won’t go into the gory details of how GWO works or how to set up experiments since google’s documentation covers that pretty well. However, I will say that if you can use just one tool to make better profits from your website, GWO is definitely the one. Heck, even optimization guru Bryan Eisenberg says he’d take it to a desert island!

Joomla + GWO = $$?

No doubt you answered yes, so please continue reading.

Joomla is a brilliant CMS, but it’s never been easy to set up GWO experiments with it (I won’t even mention an infamous extension that would bring your site down when it misbehaved). Nonetheless, ever since Barrie North’s seminal article on using Google Website Optimizer in Joomla, legions of us began to use GWO, and our websites just keep getting better.

Ah, but we have a problem!

You’re all fired up and ready to test, test, test your website all the way to stardom and riches. You copy & paste all the codes, create your page variations, check it all out and launch the experiment. All confident, you go about your routine and come back a few hours later…. and nothing, zip, nada. GWO is not recording any visits to your site. What went wrong?

You check your page’s source code where the tracking code appears

 Joomla version 
if(typeof(_gat)!='object')document.write('<sc'+'ript src="/http'+

but that ain’t what it’s supposed to be – this is

 GWO original 
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+

notice the extra “/” inserted by joomla.

You go into a frenzy and start looking up the answers

  • You could turn off SEF, but you worked too hard for your search engine rankings to do that.
  • You could alternatively patch the SEF plugin file, which is quite techie and might lead to other problems

The Solution is Here

Frustrated from having GWO experiments fail on me, I decided to take action. The solution was so surprisingly simple, that I couldn’t believe no one had published it before. I sure spent quite a while searching online just to make sure, but as I suspected, I couldn’t find it anywhere.

Here goes (drum roll)…

Take the GWO tracking code and look for this snippet

if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+

then modify it on both the experiment and conversion joomla pages to

if(typeof(_gat)!='object')document.write('<sc'+'ript src="'+'http'+

That is a single quote, plus sign, single quote. This avoids joomla’s SEF inserting the “/” character in front of the “http”, thus rendering the tracking script invalid and foiling your experiment. It works equally well for A/B and multivariate experiments. We’ve tried it in several browsers and the javascript works just fine. Maybe Google will change their script code to everyone’s benefit, but in the meantime…

Three characters. Short, sweet. Anyone can do it. So indulge, optimize to your heart’s content!

What’s your experience with GWO and joomla ? Do you have great tips? Do share them in the comments.


You might be thinking to yourself  “What is an article about Google Website Optimizer and Joomla doing on a blog about the coolest places in Barcelona?” Honestly, I thought the same thing myself. It’s the way we at bizFlats are giving something back to the community we have learned so much from.

7 thoughts on “How to get Google Website Optimizer and Joomla to work together

  • January 23, 2010 at 08:51


    Where did you enter the snippet code for the A/B Test. I understand that the Multivariate test can be edited within the article editor.

    I’ve been looking everywhere, can you help…

    Regards, Nigel

  • January 23, 2010 at 11:33

    Hi Nigel,
    Thanks for your comment.
    We’ve also undertaken A/B tests with good results.
    As far as I have seen, there is no difference, you just add the code at the top of the joomla article on the A page, and the control scripts at the bottom.
    The upshot is that the page will load down to the beginning of the content and then jump to the B page. If both A and B have the same template, you will see little more than a blip, as the redirection takes place.

  • October 29, 2010 at 09:43

    you rock!!! this is the best. thank you.

  • January 7, 2011 at 00:18

    Thank you SO much for this! I had read some other instructions about patching files, that looked complicated and messy. But I wanted to get GWO working on my Joomla site, so needed to do something. You gave me the perfect answer! This is so easy, so elegant, so simple, and it worked like a charm. Thanks for posting it!

  • January 20, 2011 at 13:27

    Thanks Deanna for stopping by. If your adventures ever bring you to Barcelona, give us shout!

  • May 7, 2014 at 19:04

    Looking forward to reading more. Great post.Thanks Again. Great.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.