How to use the new Google Content Experiments A/B testing platform to optimize your Drupal site
Tomorrow, Google Website Optimizer will no longer be available as a standalone product. Instead, Content Experiments is replacing this tool, which is integrated right within Google Analytics.
So, if your Drupal site has Google Analytics already installed (which it should have), then you can use Content Experiments to optimize your site by testing different variations of it.
For the time being, the new tool is limited to A/B Testing. Multivariate testing is not yet available.
What can you do with A/B Testing? You can create different variations of your pages and test which one performs better, conversion wise. The main things you could test are page titles, main graphics, layouts. The more prevalent the difference between the two (or more) variations, the better.
You can access the new tool from within Google Analytics navigating to the Content section of standard reports and selecting "Experiments". From there, you can create a new experiment by pressing the "Create experiment" button on the top of the page. The tool will guide you step by step to create your experiment.
The process is fairly simple. You only have to install a piece of code right after the opening <head> tag of your template. Depending on the theme you use, most probably, this should be in the html.tpl.php file of your theme.
The problem is that this piece of code should be inserted only on the testing page and not on all pages of your site. So, let's say, that the page you want to test has an internal node id of 20, so you can access the tested page at yoursite.com/node/20.
You should add the following code before the code snippet that Google provides, right after the opening <head> tag:
<span style="color: #000000"><span style="color: #0000BB"><?php <br></span><span style="color: #007700">if (</span><span style="color: #0000BB">$node </span><span style="color: #007700">= </span><span style="color: #0000BB">menu_get_object</span><span style="color: #007700">()) {<br> </span><span style="color: #0000BB">$nid </span><span style="color: #007700">= </span><span style="color: #0000BB">$node</span><span style="color: #007700">-></span><span style="color: #0000BB">nid</span><span style="color: #007700">;<br>}<br>if (isset(</span><span style="color: #0000BB">$nid</span><span style="color: #007700">)) {<br> if (</span><span style="color: #0000BB">$nid </span><span style="color: #007700">== </span><span style="color: #0000BB">20</span><span style="color: #007700">) {<br></span><span style="color: #0000BB">?></span></span>
and this one after the Google code:
<span style="color: #000000"><span style="color: #0000BB"><?php<br> </span><span style="color: #007700">}<br>}<br></span><span style="color: #0000BB">?></span></span>
This way, the experiment code that is responsible to redirect visitors to the right variation, will be injected only on node/20. Of course, you should change the number 20 on the above code with your own node id that you want to test.
The good thing with Content Experiments is that the reports that produces are not limited to conversions and conversion rate per variation. You can also see site usage per variation, such as pages/visit, bounce rate, time on site which provide a better insight of how each variation performs.
Netstudio is a Google Analytics and Website Optimizer Certified Partner. We have conducted a lot of A/B and Multivariate experiments. What I can tell after all these years of experimentation is that if you haven't started testing your site already, you're losing money!
Happy Testing!