redit 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 :
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
Google Adsense Ads Rotated by Country
Moderator: Lixas
google ads
Intertesting.. thanks for that will keep it in mind.frisky168 wrote:redit 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 :
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
.............................:: Spirit of Fire ::..................................
Re: Google Adsense Ads Rotated by Country
You could advance this to use the browser locate function from html5 so that it picks up their location (not based on browser, but based on where they currently are). That way if someone travels to another country, it takes it from their geo-cordinated position and not what they have set on the computer - like if a US person goes to the UK, it would say they're in UK, while doing it this way (the way the code is now) it would say the person is US which is false.