How to setup GeoIP to track location of IP addresses

GeoIP is a PHP extension, which is used to get all the information like, city, state, country, longitude / latitude etc for any IP address. You can use this extension to track the visitors to your site. It can help you prepare better analytic for your user-base with the information collected.
To install GeoIP, we require the GeoIP C library version 1.4.0 or higher. If you are using ubuntu or Debian, simply run the following command :

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
sudo mkdir -v /usr/share/GeoIP
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
sudo apt-get install php5-geoip

To get the data for any IP or domain, you can use the following PHP functions :

var_dump(geoip_record_by_name($_SERVER['REMOTE_ADDR']));
var_dump(geoip_record_by_name('www.domain-name.com'));
© 2021 WPOven Inc. All rights reserved. WPOven® and WordPress® are registered trademarks.
WPOven INC is more than just a managed WordPress Hosting that offers more secured unlimited website hosting with it’s CDN ready worldwide Datacentres.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram