Results 1 to 2 of 2

Thread: Showing ads only to 20% percent of visitors. Or different ads to another 80% visitors

  1. #1
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Showing ads only to 20% percent of visitors. Or different ads to another 80% visitors

    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You need to determine how you want to divide the ads. You could do this by time (based on the current second of the current server clock time? By hour? Etc.), or you could do this by a rotation for each visitor and track it in a database.

    Or the simplest version of this would be to use a random number. Based on your math:

    PHP Code:
    <?php
    if (mt_rand(1,5)===1) {
       
    //show the ad!
    }
    else {
       
    //alternative content, or omit this else block
    }
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •