How to get login user's City so that I can serve location based content with collection that's appropriate?

What is the best way to get users geolocation after user has login? Does account-UI or account-password have it? An example with a simple shopping cart would be appreciated.

EDIT: Wanting user’s City and not Geolocation thanks

Check out


Hi Sean,

Thanks but this is implemented in Go?

You can get the ip using: (in the browser)

then just pass the response to freegeoip.

what about the html5 geolocation option? or a google places input for exact lat/lng?

or get their zipcode if you don’t need exact lat/lng…


Honestly, if they will give it to you (heh), has it right – html5 is the way to go. My experience has been that using the ip is less accurate but has a higher success rate.

So get the IP first and then use either geocoder or freegeoip? or as mentioned use html5 geolocation directly? Changed from geolocation to city requirement.

Here is an example of lat/lng using autoform and google places:

if you just need the city you could have an array of cities and do a dropdown. Or you could still use the google places api and just pull out the city… but you probably need an form input for them to type into.

Is your goal to get their location without asking? If so, the IP is your best bet. HTML5 will do a popup asking them if it is okay that you get their location, which may be creepy if your audience isn’t a younger crowd

Hi Anthony,

No, it is more like a simple shopping cart that shows everything, and then when user selects via checkboxes, then based on the City Location, only certain items from collection are served. i.e. BBC1 then once clicked another page will only serve London based channels if you are in London, etc