Welcome to WebmasterWorld Guest from 54.198.90.50

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)

Junior Member

5+ Year Member

joined:May 17, 2007
posts: 101
votes: 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
8:16 am on July 31, 2012 (gmt 0)

New User

joined:June 8, 2011
posts:6
votes: 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 July 31, 2012 (gmt 0)

Senior Member

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

joined:Apr 19, 2002
posts:3181
votes: 9


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 July 31, 2012 (gmt 0)

Moderator from CA 

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

joined:Aug 29, 2003
posts:4059
votes: 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()