| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | Split Test help 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. |
| |
| | #3 (permalink) |
| NamePros Regular | 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? |
| |
| | #4 (permalink) |
| NamePros Regular | ------------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 = "http://www.searchnut.com/?domain=domain.com";
$url_two = "http://park.parkingpanel.com/domain.com";
$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;
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>domain.com</TITLE> </HEAD> <FRAMESET rows="100%,*" border=0 frameborder=0 framespacing=0> <FRAME name=top src="<!--#exec cgi="/split_test.pl" -->" noresize> </FRAMESET> <!--#exec cgi="/counter.pl" --> </HTML> |
| |
| | #6 (permalink) | |
| Senior Member | Quote:
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |