Search code examples
sitecoresitecore8sitecore-xdb

Access Geolocation service programmatically


I am trying to use Sitecore 8.1's Geolocation service to detect customer's location and serve correct site context.

Is there an API from them that I can use programmatically? Any sample code?


Solution

  • You really shouldn't. The service isn't meant to be called synchronously in your page requests - holding up the site page delivery until you have an answer. It simply won't perform very well.

    Sitecore Marketplace offers the GeoLite Resolver (Github link: https://github.com/adoprog/Sitecore-Geo-Lite-Resolver), and while this is fairly old it can still be included and compiled in your Sitecore 8 projects just fine.

    It basically uses an offline light copy of the MaxMind database - good enough to solve country resolution (but not city) - and can respond very fast (<10ms) to a lookup.