The quick answer is that you should always use option #1 over option #2. When you make a request to
LookupManager.GetInformationByIp(), this makes a direct service call to map the ip to a location. That might seem to be what you are trying to achieve, but there are several issues with that. Including some of the following:
- No caching to return previously looked up Ip Addresses
- Before Sitecore 9, or if you are using your own Geo IP Service, you could be looking up IP addresses unnecessarily, which will cause you to incur more credit expenses ($$$).
- Subsequent IP Lookups will return results slower than if you returned them from local caching or lookup tables.
GeoIpManager will check internal caches and databases to see if that IP has been requested before, which will result in several benefits to your application. Some of the steps that take place include (these may vary based on the version of Sitecore):
- Access Data Dictionary of recent lookups in memory
- Access GeoIp Table of Ip Address Mappings
- Use Service to Lookup Ip
- Store resolved service ip to geo information in data dictionary/ip table.
It's also important to note that if you are just trying to get the current users country code for example, it probably would make more sense to use the current Tracker, using
Sitecore.Analytics.Tracker.Current.Interaction.GeoData.Country will return a string value of the country.
Keeping in mind that with most of the options above, you are unlikely to have the Geo Ip information available on the first page load (unless you run the service calls synchronously which isn't recommended).