views:

29

answers:

1

I'm going to be using Google Website Optimiser (GWO), possibly on quite a few different sites. In theory it's straightforward: paste the validation Javascript code in the head and footer of a few pages you want to test:

http://services.google.com/training/websiteoptimizeruserguide/

The problem is when you use a CMS with dynamically generated urls.

Let's say I know the url of the page I want to test is: ...index.php?option=com_content&view=article&id=54&Itemid=69

What I'd like to do is save the GWO javascript in a file like mygwo.js, then put some code in the head of index.php which will only call the javascript file if the url matches the url above.

This means I would be able to install all the GWO code by only editing index.php.

I'm guessing I need something like "php include only if", but I'm pretty green on php.

Thanks for your time.

A: 

Find a unique pattern in the URI or somewhere, for example if all pages with GWO have &view=article then:

<?php 
define('SHOW_GWO', isset($_GET['view']) && $_GET['view'] == 'article' );

if ( SHOW_GWO ) {?><script src='blah.js'></script><?php } ?>
meder