Login · Register
Home About Blog

Split Testing Landing Pages With Tracking202

In this section we will show you how to split test several landing pages with Tracking202. All we are basically is going to do is make an-ever-changing landing page that rotates between several landing pages. It is really quite simple.

In Tracking202 you'll want to add several landing pages, you can denoate them differently for example: landingpage1, landingpage2, landingpage3 as the nicknames. For the URL just go ahead and set all the landing page URLs to the same page, as this page will rotate between all three of these landing pages. Let us say for instance you will be sending your visitors to example.com/landingpage.php, ok, so then put that as your landing page URL.

Now grab the landing page code for each of these new landing pages, and then put the code on different pages. For instance, landingpage1.php, (put the landingpage1 JS code on there), then make landingpage2.php, (put landingpage2 JS code on that one), and so on forth, for how many landing pages you have.

So now you have, in this example, we have 3 different landing pages, each has been added into Tracking202, and there is a unique .php file for each of the landing pages on your domain. In T202 all your landing page URLS should point to: example.com/landingpage.php. Now what we are going to do with landingpage.php is simply rotate between the three different landing pages; landingpage.php when you land on it will simply include the different landing pages. Below is the code you'd use for landingpage.php

The PHP Code


//Tracking202 Landing Page Rotation Script

//landing pages filenames, theses will be rotated between eachother
//theses landing pages must be in the same DIRECTORY as this file
//you can add as many landing pages here as you like
$landingpage[1] = 'landingpage1.php';
$landingpage[2] = 'landingpage2.php';
$landingpage[3] = 'landingpage3.php';

//this is the text file, which will be stored in the same directory as this file, 
//count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
$myFile "count.txt";

//open the txt file
$fh = @fopen($myFile'r');
$lpNumber = @fread($fh5);

//see which landing page is next in line to be shown.
if ($lpNumber >= count($landingpage)) {
$lpNumber 1;
} else {
$lpNumber $lpNumber 1;

//write to the txt file.
$fh fopen($myFile'w') or die("can't open file");
$stringData $lpNumber "\n";

//include the landing page

//terminate script



So that above code should be placed on landingpage.php; whenever that file is called it will include the other landing pages, and it will rotate between them evenly. Now you are rotating between your landing pages, in Tracking202 when you goto ANALYZE » LANDING PAGES, you can now tell the difference how each individual landing page performs.


  1. Wes (MasterlessSamurai.com) on Aug 25, 2008 at 12:18pm

    I wonder if on a future update that this functionality could be coded as part of one of the steps when setting up landing pages. You could have a pull down of sorts, enter in your configuration details, and have the outputted code ready to split test offers.

  2. matt on Nov 14, 2008 at 12:45pm

    hey wes, do i need to create new outbound URL's for the offers?...like landingpage2 needs to link to the offer page with a different uRL?

  3. matt on Dec 14, 2008 at 10:45am

    hey guys - will this work for html sites?? - guess integration of php script means changing all to php....!!

  4. Chad on Dec 18, 2008 at 2:15pm


    you can force your .htm/.html files to be parsed by php if you update your .htaccess to include:

    RemoveHandler .html .htm

    AddType application/x-httpd-php .php .htm .html

  5. Wes Mahler on Dec 18, 2008 at 11:33pm

    @Matt 2) Yes you need to setup each landing page with its own outbounds.

    @matt 3) You'll want to change it to .php, thats the easiest, or do matt's trick.

  6. Sean on Jan 07, 2009 at 11:43am

    Here's a bit more of a generic version that randomly picks a file in the current directory matching lp_*.php. It's not necessary to cycle in order, nor should it be necessary to specify the list of landing pages in advance.

    Call this index.php and put it in your directory, ie /landingpage. Put your individual landing pages in the same directory, make sure they have a .php extension, and begin with lp_.


    /* Landing page rotator


    * Picks a random landing page out of all the ones in the current directory

    * Name your landing pages staring with lp_ and ending with a .php extension

    * ie lp_blue.php


    * Released to the public domain, [email protected] 2009


    $lp = glob("lp_*.php", GLOB_NOSORT);



  7. shane on Jan 09, 2009 at 10:09am

    what about setting a cookie to make sure the same landing page is served up when they return? not everyone performs your desired action on the very first visit

  8. primesgenato on Jan 10, 2009 at 9:53am


    Reading and writing to a file just to determine what LP to show gives BIGTIME overhead for your server. No problem if your traffic is small but if you have many thousands of hits, then your solution isn't very efficient. Multiple processes hitting your page at the same time will also be forced into a wait condition simply because only 1 thread can read/write your "count.txt" file at the same time.


    Your solution is better, though there is still unnecessary overhead because it forces the server's underlying OS to do a file search based on your "*" wildcard. It also forces me to name my LPs in a certain way and to be in the same directory. I personally just have an array of URL LPs which can have any name I want, and be in any location, even on another server. I then use the "array_rand()" function to pick a random LP to show.


    # Array of LPs

    $lps = array(





    header('Location: ' . array_rand($lps));



    Good idea! You're right. I never thought about that. :)

  9. Wes Mahler on Jan 10, 2009 at 12:58pm

    @primesgenato agreed, but it was really the easiest way to set it up so it'd rotate evenly without much work or SQL's being needed.

  10. affiliate software on Jan 12, 2009 at 10:07pm

    so where does this stand? whats the leanest/meanest way to rotate and spit test?

    wes, if my dedicated server is getting under 20k a day to it, is this script y0u have provided ok to use?


  11. primesgenato on Jan 13, 2009 at 8:55am

    @affiliate software

    Using my script is MANY MANY MANY times faster than Wes's or even Sean's script. This is because no additional overhead is incurred in calling the server OS to read/write files/directories.

    But if you've got a dedicated server with plenty of resources to spare, then you can afford to choose any split testing script you want. Should not be a problem if it's less than 20k. Though I'm assuming it's spread out evenly throughout the day, and not all 20k hits in an hour!

    Just monitor your server usage daily to see if they're being maxed out. Or check with your support techs if you wanna be sure your server is holding up alright. :)

  12. Steffen on Feb 06, 2009 at 5:13am


    There is a error in your script. It should look like this:


    $lps = array(





    header('Location: ' . $lps[array_rand($lps)]);


    array_rand returns the array element number.

  13. Jimmy on Feb 06, 2009 at 9:12am

    How can I use primesgenato script to track keywords?

  14. Yacobi on Feb 07, 2009 at 4:13am

    I've created a version combining the best of the versions above - performance, simplicity and not using a redirect so the referrer and parameters won't be lost. Tried it with html also and it worked:


    //Tracking202 Landing Page Rotation Script

    //landing pages filenames, theses will be rotated between eachother

    //theses landing pages must be in the same DIRECTORY as this file

    //you can add as many landing pages here as you like

    $landingpage[1] = 'LandingPage1.php';

    $landingpage[2] = 'LandingPage2.php';

    $lpNumber = rand(1,count($landingpage));

    //include the landing page


    //terminate script



  15. primesgenato on Feb 11, 2009 at 1:28am


    Good call! I just typed out the code without checking the syntax for correctness. Sorry about that.

  16. Sean on Feb 16, 2009 at 7:15am


    If you're worried about the syscalls associated with the glob, then you've got problems. strace apache some day and you'll see all the stuff that goes on behind the scenes, this is nothing compared to the existing overhead, especially if the request goes to the PHP module.

    Your points about the LP needing to be in the same directory are of course very valid. My approach has been to fit my workflow around this limitation.

    Anyway, rather than speculate, I put both my script and yacobi's on my workstation and ran ab against it. The results are virtually identical on my PC, which is not at all tuned for the load. If I used 500 landing pages in my solution I could make it worse, but with 10 LPs there was no discernible difference.

    YYMV, IMHO, etc.

  17. Logan on Feb 16, 2009 at 3:14pm

    Maybe I am missing something, but what landing page do I then select when in the "Get links" area of prosper202 to create my link to give to Google AdWords? Do I setup my index page as a landing page as well? For your example, the landing pages created would be:





    Or is there something else I would do?


  18. Wes Mahler on Feb 16, 2009 at 10:39pm

    @Logan, making an index.php file would be a good idea, yes that should work!

    and then it'll rotate between ur landingpage1-3.php

  19. chris on Feb 18, 2009 at 8:13am

    Hey did anyone come up with anything to solve shanes query on the same landing page coming up if a user returns?


  20. albonya on Feb 19, 2009 at 6:48pm

    2 Questions:

    1. How do you test this to make sure it's rotating properly?

    2. For the separate outbound redirect pages, do we also need to create separate versions of the offers in Tracking202 so that the redirect codes are different for each landing page?

  21. Steven on Feb 20, 2009 at 12:38am

    @Chris - not at the current moment but we'll be releasing something in the future for Pro on this

    @Albonya - You would need to enter the rotate.php script into a browser and make sure its evenly rotating through the pages and that the hits are showing up in SPY. As for the outbound, if its using the rotate script and is on the same domain, you just need to add the exact URL structure for LP setup.

  22. rideswitch on Feb 25, 2009 at 10:44am


    I used your script to rotate my landers on wordpress. What effect would a redirect have on t202? Is there any? Your's was the most simple and quickest code, why were other people discussing "includes" if a simple redirect works well?


    $lps = array(





    header('Location: ' . $lps[array_rand($lps)]);


    Thanks, RideSwitch

  23. Dan on Feb 28, 2009 at 11:07am

    If you are using iframes... this doesn't seem to work. I am not the coder, but is there something I can change to make that work?

    These are multiple iframed offers and I am trying to rotate them.


  24. dave on Mar 11, 2009 at 7:52pm

    how would you do this if you want to test out your home page which happens to be a forced optin page?

    if you're ranking for seo how would this play in?

  25. ImagesAndWords on Apr 25, 2009 at 9:52am

    I wrote up a more detailed tutorial on how to set this up here: http://profitapolis.com/featured/how-to-split-test-landing-pages-with-tracking202.html

  26. Dean on Aug 06, 2009 at 12:37am

    What code to add to the script if we want it to rotate our landing pages after 10 times of impression for each?

  27. Wini on Aug 10, 2009 at 8:36am

    I've just setup my landing page split test as above - it works fine. But the question is now:

    If I'm going to buy traffic I must setup a PPC campaign and associate this with one special affiliate network/campaign but I'm split testing with different networks and merchants (I'm doing not only landing page split test also offer rotation).

    Are the traffic costs calculated correctly if I do a split test this way?

  28. Yebot on Aug 13, 2009 at 10:30am

    Someone asked about using cookies to show the same LP to the same user if they come back later. Here's how that might look:


    Other mods:

    -- set how long until cookie expires

    -- uses a header redirect instead of an include

  29. Kris - Cashtactics.net on Aug 28, 2009 at 9:20pm


    Did you code that up yourself?

  30. Mac_User on Sep 07, 2009 at 12:32pm

    I'd like to utilize this script for my PPV offers. Is there any way in prosper202 to monitor actual page clicks on the landing page. With PPV, the landers are automatic clicks (almost like an impression) that are shown to the user. When a user clicks on the "submit button" on a lp, there is no way to follow the clicks other than to go the network to see the clicks and conversions (of course in p202, you will also see conversions due to pixel tracking).

    Any thoughts...

  31. Magnus on Sep 16, 2009 at 6:44pm

    Hello, Maybe I should check the forums for the answer to this... but figured I would post my experiences here.

    I have setup everything correctly and have now tried all 3 versions of the rotate script... mentioned above. starting with the first.

    The reason why I tried the others is because I was running into the following issue... and still am.

    The pages rotate just fine, but when i click on one of the links it is adding an incremental number to the end of the domain making the destination of the redirect fail to load...

    I'm guessing that this is the 'count' this should probably be reporting to the count.txt file? I really don't know...

    I'm unable to execute 777 files so my server admin told me to set the count.txt file to 644 and said it should be fine...

    So In an effort to get around the count.txt file i tried using the code by Yacobi above... which appears to not use the count.txt file, yet I'm still getting the incremental number at the end of each redirected destination url...

    any suggestions?

    it just dawned on me that this may be the cloaked subid information...

    For my offer affiliate link I put my own url because i'm using an iframe for the offer lander...

    In this case. what is the correct setup?

  32. Martin P. on Sep 25, 2009 at 4:35pm

    Hey, I'm trying the code in my wordpress blog. It works fine but I am using GeoIP on my page and when I use the rotate.php to rotate the pages (because they are pages in WP) it is not showing anymore my city (Montreal) but Houston !! I guess because my server (HostGator) is located in Houston.

    Do you know how I can fix that ??

  33. Devon on Oct 16, 2009 at 9:39am

    If we're rotating between Advanced LP's and Simple LP's - Which "Get Links" do we use since it asks for Simple or Advanced? My split testing script will be displaying both simple and advanced....

  34. Bob on Nov 04, 2009 at 2:53pm


    Thanks for sharing your script... but It's not rotating evenly... it sometimes takes 2 or more clicks before it moves to the next page...

    The original script above doesn't work, does anyone have a fix for it please?



  35. jive on Dec 30, 2009 at 3:12pm

    Wes' updated script from: http://prosper.tracking202.com/forum/13/25/landing-page-rotator-question


    //Tracking202 Pro Custom Landing Page Script

    $parsed_url = @parse_url('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);

    $query = $parsed_url['query'];

    //landing pages filenames, theses will be rotated between eachother

    //theses landing pages must be in the same DIRECTORY as this file

    //you can add as many landing pages here as you like

    //this includes all of the get urls

    $landingpage[1] = '/lp1/index.php?' . $query;

    $landingpage[2] = '/lp2/index.php?' . $query;

    //this is the text file, which will be stored in the same directory as this file,

    //count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.

    $myFile = "count.txt";

    //open the txt file

    $fh = @fopen($myFile, 'r');

    $lpNumber = @fread($fh, 5);


    //see which landing page is next in line to be shown.

    if ($lpNumber >= count($landingpage)) {

    $lpNumber = 1;

    } else {

    $lpNumber = $lpNumber + 1;


    //write to the txt file.

    $fh = fopen($myFile, 'w') or die("can't open file");

    $stringData = $lpNumber . "\n";

    fwrite($fh, $stringData);


    //redirect to the landing page

    header('location: ' . $landingpage[$lpNumber]);


  36. tc on Mar 15, 2010 at 11:51am


    I had the same problem where the rotation would only sometimes work. Specifically IE Windows would never rotate but Firefox and Mac would.

    Traced the problem having just 2 pages to rotate and to clicktale - the clicktale bot would come in after Windows IE, and request the page, effectively reseting the rotation.

    Do you have any javascripts or anything else that would cause a browser to re-request the page?

  37. cale on Apr 14, 2010 at 1:52pm

    hey were do u put this code at in the html im useing dreamweaver cs3 to make php files on my apache webserver

  38. The_Jackal on Jan 21, 2011 at 3:00pm

    When setting up multiple landing pages, what do I put in as my URL for text ads? Can I not split test ads when I'm also split testing landing pages? It seems that when getting links for text ads, I always have to choose a specific landing page. Someone please help! Can't seem to find a definite answer, and I'm not too code smart.

  39. Ray on Mar 18, 2011 at 7:46am

    Instead of using a random number to determine what landing is to be served, you can base the computation on the visitor IP address. Then, as long as the visitor comes back later with the same IP address, he will see the same landing page.

    So, instead of this:

    $lpNumber = rand(1,count($landingpage));

    use this:

    $lpNumber = str_replace('.','',$_SERVER['REMOTE_ADDR']) % count($landingpage);

  40. Seth Boston on Apr 16, 2012 at 9:10pm

    If your looking for a highly advanced offer rotation script that compliments p202 nicely, check out http://offerwarrior.com

  41. William on Jun 19, 2012 at 3:27pm

    I have no idea how to actually use this files or how to link it up. A video would be really useful for us who are php gurus.

  42. William on Jun 19, 2012 at 3:28pm

    I have no idea how to actually use this file or how to link it up. A video would be really useful for us who aren´t php gurus.

    Sorry a bit tired. My previous statement didn´t make much sense.

  43. Karl on Aug 03, 2012 at 7:29am

    Works perfect, wish I'd set it up sooner!

  44. David on Aug 31, 2012 at 8:42am

    How do i rotate 2 landingpages with a direct link

  45. Kirito on Dec 21, 2012 at 12:30pm

    Can someone tell me how to create a PHP page from OptimizePress theme? Thanks.

  46. AL on Jan 03, 2013 at 11:34am

    @Wes is there a way to track the performance of the split landing pages? I can get it to rotate evenly but it's only tracking performance of the PPC ad and not the rotated LPs itself.

  47. Justin on May 05, 2013 at 12:07pm

    Hi guys,

    I have made a campaign on prosper202, with rotating landingpages and rotating offers. Everything tracks well, but only the clickouts not.

    Every clicks ( include not outgoing click) are clickouts, so I can't track the LP CTR.

    Can someone help me to solve this problem?

    If you need more details, i can give.

    Hope to hear from you.



  48. Jack on Oct 08, 2013 at 5:34pm

    So what I basically have to do, is make all the landing pages I want to split test. Set up each of them in Prosper202. Then put the HTML code that above in the main lander. And copy and paste the Landing Page Codes to each landing page I want to split test. I will try this out. Very powerful stuff!

  49. Nabru on Aug 04, 2014 at 10:33am

    How can I pass 7search variables like AFFID and RID with this script?

Leave a Reply

Name (required)

Email (will not be published) (required)


What does 4 + 4 equal? (required spam filter)

Creative Commons License This work (Prosper202, Tracking202 and Export202) is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.