denhamd2 Posted May 18, 2007 Share Posted May 18, 2007 Hi, I'm trying to set up a simple A/B test using PHP. I tried just using a random script, where it goes to either page1 or page 2 randomly through the redirector page. However i notice it doesn't give a 50/50 split, ie attempt 1 it went to google, attempt 2 it went to google, attempt 3 it went to yahoo. i need for instance a counter where all the even numbers go to google and all the odd numbers go to yahoo, that would be the most accurate way i could think of without having to use a database (which I want to stay away from). therefore, is there a way i could maybe have a counter stored in a text file where it increments for every visit and all the odd numbered hits go to one page and all the even numbered hits go to another. would anyone know how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/ Share on other sites More sharing options...
taith Posted May 18, 2007 Share Posted May 18, 2007 sorry... i dont fully understand modulo... but i think this'd work... $_SESSION[counter]++; if(($_SESSION[counter]%2)==0) header('Location: '); else header('Location: '); Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256224 Share on other sites More sharing options...
denhamd2 Posted May 18, 2007 Author Share Posted May 18, 2007 my problem is I want exactly 50% of my traffic to be redirected to 1 page and exactly 50% to the other. With the random redirector it isn't totally accurate, everytime i refresh sometimes it goes to the same page 2 or 3 times in a row before going to the alternate page. i was thinking if i could have a counter of some sorts, it could get the hit number for each customer and all the odd numbered hits go to 1 page and all the even numbered hits go to the other page. Do you follow? Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256226 Share on other sites More sharing options...
taith Posted May 18, 2007 Share Posted May 18, 2007 yup! just store the counter into the database... instead of in a session :-) Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256227 Share on other sites More sharing options...
denhamd2 Posted May 18, 2007 Author Share Posted May 18, 2007 i'm looking not to use a database, a simple text file if possible anyone know how to go abot coding this? Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256264 Share on other sites More sharing options...
marf Posted May 18, 2007 Share Posted May 18, 2007 use a csv text file? and have one entry to represent one and the other represents the second page. Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256266 Share on other sites More sharing options...
denhamd2 Posted May 18, 2007 Author Share Posted May 18, 2007 im a bit of a newbie so would it be possible ot tel me how do set that up? Quote Link to comment https://forums.phpfreaks.com/topic/51984-simple-ab-testing/#findComment-256270 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.