Page rotation

I want to do A/B testing on different sales pages for my e-books.  I wrote up 4 different versions and named them “psst.A”, “psst.B”, etc.

I have a cron job that runs this Perl script every day:

#!/usr/bin/perl
open(I, “data/abcontrol”) or exit 1;
@c=<I>;close I;
$a=pop @c;
exit 0 if not $a;
open(I, “>data/abcontrol”) or exit 1;
print I “$a”;
foreach (@c) {
print I “$_”;
}
close I;
chdir(“data/text”);
chomp $a;
exit 0 if not $a;
$cmd=”cp psst.$a psst.html”;
system($cmd);
open(O,”>>data/abcontrol.dates”);
$date=localtime();
print O “$a $date\n”;
close O;

The “abcontrol” file contains “A”, “B”, “C”, “D”, one  per line.  This swaps in the next variant and records the time for the running page to a file.  I can later compare that file to sales figures to see which page did better.

After the first run, “abcontrol” will have “BCDA”, then “CDAB” and so on – constantly rotating which page to use next.

But that’s silly:  why not just store a “D”, decrement to “C” and store it back and so on to “A” and then go to “D” again?

But why even do that?

#!/usr/bin/perl
$a=((localtime)[7]  % 4 + 65);
$cmd=”cp psst.$a psst.html”;
system($cmd);

That (localtime)[7] is the day of the year, so mod 4 it’s 0-4, add 65 it’s A-D.

No log file needed either as we always know when “A” ran.

Advertisements

One Response to “Page rotation”

  1. Tony Lawrence Says:

    Google has a tool to do this for you:

    http://www.google.com/websiteoptimizer#utm_source=referrer%3A%2Bwmastertools&utm_medium=marketing%2Bmedium%3A%2Bwtpage&utm_campaign=WTXPromo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: