Geo-Targetting YPN ads

Status
Not open for further replies.

owningmonkey

New member
Nov 9, 2006
19
0
0
what kind of scripts do you guys use to geotarget your YPN ads? I found one that works if you only have one ad on your page but when i try to ad a second one i get an error. Here is my code..

Code:
<? 
// 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 "United States": { ?> 
 
YAHOO ADS!!!!!!
 
<? } 
   //break; 
//case "United States": { ?> 
 
<? //} 
    break; 
// AND SO ON, YOU CAN ADD MORE COUNTRIES HERE JUST LIKE ABOVE 
default: { // THIS WILL EXECUTE FOR ALL OTHER DESTINATIONS NOT MENTIONED ABOVE ?> 
 
GOOGLE ADS!!!!!!!!
 
<? } 
} 
?>

how could i make this so i can place more then one ad on a page? thanks
 


I called YPN about this and they are suggesting publishers use this for filtering international traffic --


GeoLite Country is an open source IP address to country database. Here
is the link to the free and paid versions of the product, along with
various licensing documentation:


MaxMind - GeoLite Country | Open Source IP Address to Country Database.

We can also direct you to a post on Search Engine Roundtable that
contains instructions on how to implement this product:


Blocking Yahoo Publisher Network Ads from Internation Traffic
 
Andrew with that one do you just keep posting that code on the page if you want it in 2 different spots. I was looking for more of a solution.. where it opens the geoip.dat only ONCE and then you have a code that displays off of that a number of time. It doesnt make sense to search the file two times each page visit.
 
You don't open the file twice. Just open it once to query and then save the value for subsequent checks. You already have the value so there's no need to open the file again. Even in the code you posted, you save the value in $visitor_country_name. All you do is check it. I don't see what would even give you the idea to query the file twice for one IP.
 
Because im not a programmer. So what part out of my code do i paste somewhere else to have another geo targetted ad show up? Everything except $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); ??

Thanks.
 
PHP:
switch ($visitor_country_name) { 
case "United States": { ?> 
 
YAHOO ADS!!!!!!
 
<? } 
   //break; 
//case "United States": { ?> 
 
<? //} 
    break; 
// AND SO ON, YOU CAN ADD MORE COUNTRIES HERE JUST LIKE ABOVE 
default: { // THIS WILL EXECUTE FOR ALL OTHER DESTINATIONS NOT MENTIONED ABOVE ?> 
 
GOOGLE ADS!!!!!!!!
 
<? } 
} 
?>

That's all you need to repeat since you already have the $visitor_country_name.
 
Status
Not open for further replies.