Dynadot โ€” .com Transfer

Split Test help

Spaceship Spaceship
Watch

blaknite

Established Member
Impact
35
I managed to muck together a simple stats logging script a while back. It just grabs the stats I wan't and loads the parking company lander in an Iframe. Fairly simple...

Anyhow I just bought a new high traffic adult domain and I want to split test it between several parking services to see who pays the best. I know I can use CGI/PHP and the basic concepts needed to write the script aren't out of my reach. Where I'm stuck is I don't know how to track which company I sent the last visitor to so I can send the next one somewhere else. At least not efficiently. I could save a counter in a file then load it on the next visit. Accessing from a file seems like the wrong way to do it though. Is there some sort of global variable that doesn't get reset from one execution of a php or cgi script to the next?

I don't know if it makes any difference or not, but it seems like opening and reading a file would create overhead and slow down getting my visitors to the lander. I'm sure I can make this work using the file idea. It just seems I'm missing something obvious that would make it much more simple.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Why not use a database for this? Almost all hosts provide MySQL these days anyway. Granted, it wouldn't be as fast as an in-memory variable lookup, but it's still much faster than disk.
 
0
•••
I definately have access to mysql databases. I've used one before to setup a wordpress install, so I know they are there. I'll have to look into it, as I have never programmed anything using a database. It seems like that might be overkill. I only need at most 1 byte of storage to carry from one script execution to the next.

On further thought file access migh just be the easiest way to go. We are only talking a few hundred uniques per day at most. I just don't like the thought that I may lose some clicks because a page doesn't load fast enough. Probably just needless worry though.

Can someone explain why a MySql database access would be faster than a file read?
 
0
•••
------------UPDATE-------------
I've got it working now, I just thought I'd stop back and post the script I came up with in case someone else might be able to use it.

Heres the code for the file split_test.pl
Note you want to replace the green part with your parking company's url!
Code:
#!/usr/bin/perl

$url_one = "[COLOR=SeaGreen]http://www.searchnut.com/?domain=domain.com[/COLOR]";
$url_two = "[COLOR=SeaGreen]http://park.parkingpanel.com/domain.com[/COLOR]";

$url_list_file = "url_list.txt";

open (FILE, "+>>" . $url_list_file) || die "Failed to open url list.\n";
flock (FILE, 2);
seek FILE, 0, 0;
my $lasturl = <FILE>; 
truncate FILE, 0; 

if ($lasturl == 1){
   $url_dest = $url_two; 
   print FILE "0";
} else {
   $url_dest = $url_one;
   print FILE "1";
}
flock (FILE, 8);
close (FILE);

print "Content-type: text/plain", "\n\n";
print $url_dest;
exit;

Here is the index.html that executes the Cgi script. Replace the part in green with your domain name. The Part in red runs my stats counter script. You'll want to either replace or remove it.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
	<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<TITLE>[COLOR=SeaGreen]domain.com[/COLOR]</TITLE>
</HEAD>
<FRAMESET rows="100%,*" border=0 frameborder=0 framespacing=0>
	<FRAME name=top src="<!--#exec cgi="/split_test.pl" -->" noresize>	
</FRAMESET>
[COLOR=DarkRed]<!--#exec cgi="/counter.pl" -->[/COLOR]
</HTML>

Last but not least, you will need to create a file called url_list.txt in the same directory as these two files on your server. The script will overwrite the file everytime it is run, but I am pretty sure it has to be created manually for the first run. It doesn't matter what is in the file, it just needs to exist and have the right file permissions so the script has a scratchpad to keep track of where it sent the last visitor.
 
0
•••
Just to let you know - that's invalid HTML. All HTML tags and attributes are lower-case.
 
0
•••
Mikor said:
Just to let you know - that's invalid HTML. All HTML tags and attributes are lower-case.

In HTML it does not matter. It matters when you are using XHTML
 
0
•••
Really? The w3c validator says otherwise.

edit: Ahh, I didn't read the output fully. The doctype is incorrect, the Frameset doctype should be used, not Transitional.
 
0
•••
Appraise.net
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back