Welcome to WebmasterWorld Guest from 54.161.228.30

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Showing ads only to 20% percent of visitors

   
7:50 am on Jul 31, 2012 (gmt 0)

5+ Year Member



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
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.
8:24 am on Jul 31, 2012 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.
1:16 pm on Jul 31, 2012 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



<?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()