Calling Sitecore Geo IP Location Service

The Sitecore Geo Location IP functionality can be used for a lot of things, and it gets automatically called in the normal sitecore pipeline, at which point you can just ask for the Country, City etc. from the current contact. However, there are cases when you want to use this information before it’s available (i.e. before Sitecore pipeline calls the Geo IP location service.

If you do call the interface yourself, you need to make sure that the standard caching is used to not increase the amount of calls. In some articles, the recommendation is to call GeoManager.GetGeoIPData(). However, as it’s been noted elsewhere, this won’t work correctly as that’s an internal analytic related API, and it caches the results using the ID. Sure you can provide your own ID, but you’re basically messing Sitecore analytics at this point.

Which calls the correct Geo IP Location Provider (Sitecore.CES.GeoIp.SitecoreProvider), which includes the right caching. And the method returns you an instance of WhoIsInformation, which has the Country/City etc. information