Quick and painless geo-location
Programming, Random!, SEO, Tips & Tricks | (4)
Hey all,
I wanted to post up a quick tip for you all, since I often hear people asking about how they can implement geo-location in their landing pages.
Alot of people recommend MaxMind or some other geoIP database, but really, thats a pain in the ass...there is a much easier way to do it.
On your landing page, just include the following in header.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
This script will calculate your visitors location for you....and all you have to do is pull the ClientLocation variable!
For example, if I wanted to display a popup with the users city:
alert(google.loader.ClientLocation['address']['city'])
Seriously, its THAT SIMPLE.
Have fun!