1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

adsense scripting

Discussion in 'Placement / Reviews / Examples' started by aqrhine, Aug 23, 2006.

  1. #1
    Is there a way that I could code it so that I can put an adsense ad on one of my sites and have it set to not show the add when a certain IP range views it? I basically want to put a block on northwestern oklahoma, and a section of another state.

    The site i'm refferring to is getting around 7-8K uniques a day.
     
    aqrhine, Aug 23, 2006 IP
  2. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you are using PHP or another language to display your pages then you could insert code which checks the IP address of the individual visiting your website and then decides whether or not to show the section of the page containing the AdSense ad block. Something like:

    <?php
    $ipAddress = $_SERVER['REMOTE_ADDR'];
    $ipAddress = str_replace(".", "", $ipAddress);
    if( !( $ipAddress > 127000 && $ipAddress < 12700256) ) { ShowAdSense(); }
    ?>


    If you are only displaying static pages, then you need to make two versions of your site. One with and one without AdSense. Then you would redirect based on IP address ranges.
     
    clancey, Aug 23, 2006 IP
  3. skimmy

    skimmy Peon

    Messages:
    138
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah I set mine up so it does not show the ads if the visitor comes from an array of ip's. It certainly doesn't do a range or anything just ip's from my house, office, etc. Send me a PM if you want my code... not anything special but does get the job done.
     
    skimmy, Aug 23, 2006 IP
  4. eXe

    eXe Notable Member

    Messages:
    4,643
    Likes Received:
    248
    Best Answers:
    0
    Trophy Points:
    285
    #4
    eXe, Aug 23, 2006 IP
  5. aqrhine

    aqrhine Active Member

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Awesome thanks guys, I don't want certain people to view for personal reasons.
     
    aqrhine, Aug 23, 2006 IP