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.

Example line of theGeoManager does:


GeoIpData geoIpData = Tracker.Dictionaries.GeoIpData.Get(options.Id, LookupStrategy.CacheOnly);

The correct way to call the analytics is to call


Sitecore.Analytics.Lookups.LookupManager.GetInformationByIp(ip)

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


      ...
      Sitecore.CES.GeoIp.Caching.GeoIpCache geoIpCache = GeoIpCacheManager.GeoIpCache;
      WhoIsInformation whoIsInformation1 = geoIpCache.Get(ip);
      // etc
      ...

If you need information on how to set up Geo Location service, look at the Sitecore article:  https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/ip_geolocation/setting_up_sitecore_ip_geolocation

What are you using the Geo Location Service for?