Set up Custom Split Test Wordpress Shortcode
There are a few steps to this process, but once you do it once, you can replicate it very easily for other types of split testing.
Since I use Wordpress on my site, the first thing I did was create a custom function in my functions.php file to implement a custom shortcode that I could use on my blog posts. functions.php is a file that gets called on every wordpress page, so you can use it to put your own custom functions. If you use the Thesis Theme, there's a separate file called custom_functions.php I believe...
Inside functions.php, I put this:
This is a simple IF ELSE statement that uses the rand() function to decide which block of code to use. Over time, it will show the first bit of code 50% of the time, and the second bit of code the other 50% of the time.
Put your custom code within ob_start(); ?> //Custom code to run <? return ob_get_clean();
In this case, I've created the shortcode [youtubesub] for wordpress. So wherever I want this button to show up in my wordpress blog post, I just write [youtubesub]. It will automatically randomize which button shows up each time the page is refreshed.
Create Custom PHP file to Log Clicks and Forward User to Page
Now you could leave it at that, if you had a way to track clickthroughs on whatever page you're linking to for each button. For instance, you could do this method for adsense ads, and just track the clicks through your adsense dashboard. (But I wanted another metric to see how many people click the button because even if they do, it doesn't mean they necessarily click subscribe once they get to the Youtube page.)
You'll notice, instead of linking directly to Youtube in the code above, I link to a custom PHP file I created for this split test : Youtube.php?button=1 -OR- Youtube.php?button=2
This file figures out which button was pressed by looking at the variable passed to it in the URL, (button=1 or button=2) , saves the info in the database, then forwards the user to the destination page. The user doesn't see anything other than the result page. The script basically executes on the web server while redirecting them to the destination page.
Youtube.php is below:
This is a real bare bones approach, you could definitely expand on this. But it's a good starting point for anyone wanting to split test stuff. Also, you'd have to have already set up a table in your MySQL database and know how to connect to your database, but that's beyond the scope of this post, lol.
I was thinking you could get really fancy and set up an "automated optimizer." You could create lets say 10 different options to show, but have it only test 2 at a time. After one week, you could run a CRON script that read the database to determine which one performed better, and swap the bad one for another option. It would test that for another week, then read the data again. After 10 weeks it would have tested all 10 against each other automatically and picked the best performer.
Hope you found this useful!