Web Masters Site All For Web Masters

12Jan/110

Geotargeting with PHP

Its really important some time to use geo targeting for your web site users for example if you have e-commerci  site or for any other sites, I'll show example which give you opertunety to use geo ip with php scrip lets start.

First of all we need GeoIp base you can download it from here 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz' secend step is to download php script which I modified for our needs here is link Download Php GeoIp Script. Now extract both files in public_html, open any file where you want to add geo targeting and add this script :

include "/home/yoursite/public_html/geoip.php";
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
if($country == 'RU'){
echo "Russia";
}else{
echo "Not Russia";
}
geoip_close($gi);

Here it is thats all you can configure it at your own needs.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

 

No trackbacks yet.