Google Adsense and YPN Ads Rotated by Country

Discussion in 'AdSense' started by koydin, Feb 12, 2007.

  1. #1
    credit goes to some one scripttutorial.com

    Google Adsense and YPN (Yahoo Publisher Network) Ads Rotated by Country


    I have never liked using IP addresses to sort ads mainly because of the wasted space (Not to mention the Countless people using Proxy's) So I created a simple script to rotate my ads Based on Language and Country.

    By now anyone using YPN (Yahoo Publisher Network) knows they only pay for US Traffic - and you can lose a good bit of income by using their ads alone.

    So you could include in your Header , Footer , or Body the files named for the size and type ads you want shown :



    Code :



    <?php
    include("728x90.php");
    ?>





    For this Example - I've created a file named 728x90.php



    Code for 728x90.php :



    <?php

    $locales = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
    if ( $locales == "" ) {
    include("google-728x90.php");
    } else {
    $semicolon = array(";");
    $lesssemicolon = str_replace($semicolon, ",", "$locales");
    $breakdown = explode(",",$lesssemicolon);
    $lang_count = strtolower("$breakdown[0]");
    }
    if ( $lang_count == "en-us" ) {
    include("ypn-728x90.php");
    } else {
    include("google-728x90.php");
    }

    ?>



    The reason for the "$lesssemicolon" is due to the fact Locales may be separated by either semi-colons or commas.

    Of Course you would have to create mini php pages named "ypn-728x90.php and google-728x90.php" which simply contain your ad code(s) - Depending on size and type of ad programs you use.

    The only problems I've seen so far with this method - Is that a lot of FireFox / Opera users have never set their location on their browser , But it doesn't bother me too much seeing the Script will still show Google ads to anyone not in the US or with no locale set.

    This might actually be a good thing seeing you'll still be giving Google some US traffic as well - Thus not making them upset at you for sending them only non-US or Foreign Web Traffic.



    Hope it Helps
     
    koydin, Feb 12, 2007 IP