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.

tutorial or howto for geo targeting the ads?

Discussion in 'Publisher Network' started by jeremy860, Feb 2, 2006.

  1. jeremy860

    jeremy860 Well-Known Member

    Messages:
    935
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    110
    #21
    I am a total newbie to php so if you could like post the exact code with example ypn and adsense codes in it, that would be great, then i could just copy and paste over the example ad codes
     
    jeremy860, Feb 4, 2006 IP
  2. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #22
    I couldn't do that because I don't exactly know what you want and how you want your ads to be shown. You're the only one to know that. You'll probably need changes even after everything's done, so you'd better get a grip on php.net and have a read, it's not that difficult ;) Anyhow, if you need some php programming done you can PM me if you care to negotiate :)
     
    mihaidamianov, Feb 4, 2006 IP
  3. jeremy860

    jeremy860 Well-Known Member

    Messages:
    935
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    110
    #23
    alright well I guess i'll just continue to wait for someone to post some code that actually works for us newbies. peace
     
    jeremy860, Feb 4, 2006 IP
  4. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #24
    It's way too clear (the code above) so you could do it yourself without much trouble. In case you need something more difficult than simply copy/pasting the bits of code above, please do ask, but don't just expect for that code to simply jump into your php files... You're just being lazy!
     
    mihaidamianov, Feb 4, 2006 IP
  5. Tranix

    Tranix Peon

    Messages:
    235
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #25
    People recommended me to leave the YPN Ads on by using geotargetting so I'd like to give it a shot and see how is it going :D.

    All we need to do is uploading geoip.inc and GeoIP.dat files to directory right? Then replace $visitor_country_code with the code below? If possible can you implement these two strings code for me please

    Very much appreciated, ;)
    Tranix
     
    Tranix, Feb 4, 2006 IP
  6. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #26
    Could you be more specific with the question, 'coz I don't get what you want. You've already done most of the work.
     
    mihaidamianov, Feb 4, 2006 IP
  7. Tranix

    Tranix Peon

    Messages:
    235
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #27
    The code looks like this right?

    <?include("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); $visitor_country_code=<?
    switch ($visitor_country_code) {
    case "US": {
    switch ($vrand=rand(1,2)) {
    case 1: {
    //Display YPN ads for US visitors only

    ?> Insert YPN Ads code here <?
    }
    ?> ($gi, $_SERVER['REMOTE_ADDR']);$visitor_country_name=geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']); ?>

    :D
     
    Tranix, Feb 4, 2006 IP
  8. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #28
    Erm... no.. That is just a big mess... I'll post a bit later the code, I'm busy now.. Hold on to your seats until then :)
     
    mihaidamianov, Feb 4, 2006 IP
  9. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #29
    Step by step:

    1. Download these files:
    - GeoIP.dat from http://www.maxmind.com/app/geoip_country
    - geoip.inc from http://www.maxmind.com/download/geoip/api/php/
    and put them where your php banner script will be.

    2. The php banner script

    <?
    [COLOR="DarkOrange"]// This part gets the ip of the visitor and matches it to a country name/code[/COLOR]
    
    include("geoip.inc");
    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    
    $visitor_country_code=geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    $visitor_country_name=geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    
    [COLOR="DarkOrange"]//This part shows banners/codes that YOU decide for each country[/COLOR]
    
    switch ($visitor_country_name) {
    case "Australia": { ?>
    
    [COLOR="Olive"]<-- GOOGLE ADSENSE OR WHATEVER CODE SUITABLE FOR AUSTRALIA GOES HERE -->[/COLOR]
    
    <? }
        break;
    case "Belgium": { ?>
    
    [COLOR="Olive"]<-- GOOGLE ADSENSE OR WHATEVER CODE SUITABLE FOR BELGIUM GOES HERE -->[/COLOR]
    
    <? }
        break;
    
    [COLOR="DarkOrange"]// AND SO ON, YOU CAN ADD MORE COUNTRIES HERE JUST LIKE ABOVE[/COLOR]
    
    default: { [COLOR="DarkOrange"]// THIS WILL EXECUTE FOR [B]ALL[/B] OTHER DESTINATIONS NOT MENTIONED ABOVE[/COLOR] ?>
    
    [COLOR="Olive"]<-- GOOGLE ADSENSE OR WHATEVER CODE SUITABLE FOR OTHER DESTINATIONS -->[/COLOR]
    
    <? }
    }
    ?>
    Code (markup):
    And this is it! I'm not talking about this anymore.
     
    mihaidamianov, Feb 4, 2006 IP
    Leo727 likes this.
  10. Tranix

    Tranix Peon

    Messages:
    235
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #30
    Man, I can't thanks you enough for this awesome code :D I was searching for this code for days and almost given up.

    PS I need a few people who are living out side of the U.S. to check if you still see YPN ads on my site or not please

    http://www.tranix.net

    Appreciate a lot,
    Tranix
     
    Tranix, Feb 4, 2006 IP
  11. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #31
    I can see only one banner ad at the bottom
     
    mihaidamianov, Feb 5, 2006 IP
  12. Gregtq

    Gregtq Peon

    Messages:
    94
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #32
    This is crazy for us to have to worry about international clicks.
    I have no control over this other than adding a script to help but thats not 100%.
    If Yahoo doesn't want foreign clicks they should have this built in to their script. Sorta sounds like a game.
     
    Gregtq, Feb 5, 2006 IP
  13. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #33
    That's correct. I don't use yahoo myself, but if they don't filter the visitors' ip, who should?!
     
    mihaidamianov, Feb 5, 2006 IP
  14. keikor

    keikor Peon

    Messages:
    665
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #34
    Ok, let me get this more clearer for myself and others:-

    So, the first step is to download both of the files and upload to your directory where you are using.

    Then insert this code to whatever page you want to use:-

    <?
    // This part gets the ip of the visitor and matches it to a country name/code
    
    include("geoip.inc");
    $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
    
    $visitor_country_code=geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    $visitor_country_name=geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']);
    
    //This part shows banners/codes that YOU decide for each country
    
    switch ($visitor_country_name) {
    case "USA": { ?>
    
    <script language="JavaScript">
    <!--
    ctxt_ad_partner = "xxxxxxxxxx";
    ctxt_ad_section = "";
    ctxt_ad_bg = "";
    ctxt_ad_width = 250;
    ctxt_ad_height = 250;
    ctxt_ad_bc = "FFFFFF";
    ctxt_ad_cc = "FFFFFF";
    ctxt_ad_lc = "FFFFFF";
    ctxt_ad_tc = "111111";
    ctxt_ad_uc = "111111";
    // -->
    </script>
    <script language="JavaScript" src="http://ypn-js.overture.com/partner/js/ypn.js">
    </script>
    
    
    <? }
        break;
    
    // AND SO ON, YOU CAN ADD MORE COUNTRIES HERE JUST LIKE ABOVE
    
    default: { // THIS WILL EXECUTE FOR ALL OTHER DESTINATIONS NOT MENTIONED ABOVE ?>
    
    <script type="text/javascript"><!--
    google_ad_client = "pub-xxxxxxxxxxxxx";
    google_ad_width = 250;
    google_ad_height = 250;
    google_ad_format = "250x250_as";
    google_ad_type = "text";
    google_ad_channel ="";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "FFFFFF";
    google_color_url = "FFFFFF";
    google_color_text = "FFFFFF";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    
    
    <? }
    }
    ?>
    Code (markup):
    Correct me if i am wrong.
     
    keikor, Feb 5, 2006 IP
  15. Tranix

    Tranix Peon

    Messages:
    235
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #35
    I think you should spell out the country name USA => United Stats ;)
     
    Tranix, Feb 5, 2006 IP
  16. SamOwen

    SamOwen Peon

    Messages:
    865
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #36
    Exactly. Yahoo! should filter these out. It's obvious they already know where the clicks and views are coming from.
     
    SamOwen, Feb 5, 2006 IP
  17. keikor

    keikor Peon

    Messages:
    665
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #37
    I am getting this error when trying to put two ad banners or ad sizes in one page:-

    Fatal error: Cannot redeclare class geoip in /home/thepath/public_html/thesite/contactus/geoip.inc on line 67

    The first banner works fine but the second banner didn't

    Any help?
     
    keikor, Feb 5, 2006 IP
  18. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #38
    ummm... yeah, hold on

    you need to add this line at the end of the script above in order to be able to reopen geoipclass

    geoip_close($gi);
    Code (markup):


    or simply put it at the end of the file, and - for the second banner do not use the geoip_open line anymore. Only the SWITCH part should be repeated for each banner..

    AND START LEARNING WEB PROGRAMMING!
     
    mihaidamianov, Feb 5, 2006 IP
  19. keikor

    keikor Peon

    Messages:
    665
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #39
    Thanks a lot!

    i think i got this working, but is there anyway to check the ads with foreign i.p. address? Like any online web based proxy tools? using international i.p.?

    thanks.
     
    keikor, Feb 6, 2006 IP
  20. fmgomes

    fmgomes Peon

    Messages:
    77
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #40
    Be aware that many people have .com domains here in Europe.
     
    fmgomes, Feb 6, 2006 IP