GeoIP tracking with Google APIs

If you want to track visitors to know where they are coming from, the normal un*x’ish way of doing this is to grab maxmind‘s geoiplookup (or apt-get/rpmfind) and then run it against the web server logs. That’s so not Web 2.0. *ugh*

Google’s hosted JavaScript API’s makes this so much easier. All you have to do is include:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>

in your web page and voila’, you have the client location. How? If you directly navigate to the jsapi, you’ll see the following:

google.loader.ClientLocation

which pretty much gives you all you need to locate the user. Do a jQuery post to your web server and you know exactly where the user is coming from. Here’s a better example. The map below uses Google’s Map API to show you where you are viewing this blog from.



Bookmark and Share