| Showing ads only to 20% percent of visitors
|
basketmen

msg:4480467 | 7:50 am on Jul 31, 2012 (gmt 0) | Hi guys, how to do this in a php file Showing ads only to 20% percent of visitors. Or showing different ads to another 80% visitors any way that can work, maybe using time intervals, like the visitors that visit the site at minute 0-12 only that show it, and visitors that visit the site at minute 13-59 is not. Or another methode please help or share if you have, this should be easy enough and many people should need it, already googling it but still cant found it
|
jdilegge

msg:4480468 | 8:16 am on Jul 31, 2012 (gmt 0) | You could use a text log counter and for each pageview add +1 and every 80 pageviews show an ad. Pretty fast and low load.
|
topr8

msg:4480470 | 8:24 am on Jul 31, 2012 (gmt 0) | i'd say the quickest way would be to generate a random number between 1-5 for every page view, if the number is 1 then show the ads if it is anything else show the alternative ads.
|
httpwebwitch

msg:4480561 | 1:16 pm on Jul 31, 2012 (gmt 0) | <?php $percent = 0.2; if (rand(0,100) < (100*$percent)){ // show ads } else { // something else } ?> like topr8 said. doing things proportionally is best done using a rand()
|
|
|