Forum Moderators: open
I want to create a page that will randomly redirect a visitor to about 3 different pages. I want to test the response from the three different pages, so I'd like it to be pretty even on how often each is used.
Is there a way to do this? If so, what do I need to use?
TIA
Server-side scripting (perl, php, asp and so on) is probably a better approach, although js is not so bad, if you watch out for the "null" case as I mentioned above. A search on almost any search engine should turn up a number of pre-made scripts for a server-side approach.
site_id, site_version, site_count should be all you need. Alternatively you could also use a site_feedback, site_browser_ver. THe browser and such, as we all know can be automatically shoved to an array for storage in the mysql. Should be a simple thing to calculate which one is better after a week or two's randomness...
Thomas
p.s. as for the feedback, you can create a exit questionaire/survey with some free php/mysql code thats available.. PHPSurveyor [phpsurveyor.sourceforge.net] (sourceforge)
<Sorry, no personal URLs.
See Terms of Service [webmasterworld.com]>
[edited by: tedster at 8:19 pm (utc) on Mar. 26, 2005]
<head>
<title>Page Randomizer</title><SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var howMany = 3; // max number of items listed below
var page = new Array(howMany+1);
page[0]="http://www.example.com/page1.html";
page[1]="http://www.example.com/page2.html";
page[2]="http://www.example.com/page3.html";
function rndnumber(){
var randscript = -1;
while (randscript < 0 ¦¦ randscript > howMany ¦¦ isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</SCRIPT>
</HEAD>
<p><center>
If script doesn't work, return to:<br>
<a href="http://www.example.com">example.com</a>
</center><p>
</body>
</html>