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:

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;
chomp $a;
exit 0 if not $a;
$cmd=”cp psst.$a psst.html”;
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?

$a=((localtime)[7]  % 4 + 65);
$cmd=”cp psst.$a psst.html”;

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.


One Response to “Page rotation”

  1. Tony Lawrence Says:

    Google has a tool to do this for you:

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: