Where in the World Is the User? a Short Tale of GeoIp Confusion.

We recently rolled out a new Sitecore implementation where GeoIp was used. I'm proud of this one because we developed a neat geospatial lookup with caching that was quite efficient. All went well through QA, UAT, and even Production environment testing. Once live though, it was a different story.

We transitioned out Production environment to its real domain and some people were reporting incorrect GeoIp results. To be fair, some of these cases were unique, in that I had a User in a remote area and his IP was correctly assigned to a major hub. We also had Users with cell plans having odd IP assignments and some getting right results altogether. So, in the end there was two issues, one being simple and the other, well simple too but not as obvious.

Ok so to start with the simple issue, it was, are you ready for it? Component caching. Yes, amateur mistake but someone had enabled caching for a component with personalization, which is an issue for obvious reasons. Once disabled I assumed the situation was resolved.

The 2nd, and final correct wasn't obvious because a change was made without or team being informed. The client's IT team configured Cloudflare to be used in Production, so Sitecore was using their IP instead of the User's. the following configuration change is well documented, but the requirement isn't always so straightforward. Knowing what your client's IT team is going to do with the environment you are working in is key to a smooth rollout.

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:set="http://www.sitecore.net/xmlconfig/set/"></configuration>
  <sitecore role:require="ContentDelivery">
      <setting name="Analytics.ForwardedRequestHttpHeader" set:value="X-Forwarded-For"/>