@nick1 @rahul286 This is a great post!
I got into the exact same situation. I want to display the city on the home page based on client's ip address. I used shortcode. Currently it only displays the last visitor's city, not mine. I don't have commercial MaxMind GeoIP2 license, but use Nginx geoip module instead.
I am fairly new to wordpress. Would you mind to tell me where can I put the following code into wordpress
jQuery('body *').replaceText( '[city]', data.cityName );
In my case, it would be
jQuery('body *').replaceText( '[city]', getenv('GEOIP_CITY') );
I tried to put the code above to the active theme's functions.php. But it breaks the whole blog.