Skip to content
June 30, 2019 / kiranpatils

Sitecore Geolocation Basics

Challenge:

Sitecore Geolocation service is OOTB and available for free with unlimited lookups. And lot of great community folks have shared in-depth articles to get started. But still have seen people facing challenges with Geolocation. So, wanted to consolidate all good resources and real-world challenges in this post. So, it helps you have a smooth process of getting started with Sitecore Geolocation service.

Solution:

If you are new to Sitecore Geolocation and would like to know more about it. e.g. Why? What and How? As I mentioned earlier, few community folks have done great job blogging about it. I will share few of those here:

How can I activate Geolocation?

With Sitecore 9, Geolocation is available OOTB. You just need to activate it from App Center. For that you have to login to App Center. To login and activate, you need to either use same email address which you used for purchasing your Sitecore license or contact your Sitecore contact, and s(he) will give you one Form (PDF) using which you can allow other user to access App Center.

Once you login and activate Geolocation from Appcenter. You should be all set. If your environment is scaled, you just need to get this activated from CM only.

You need to do this one-time activity for all your environments e.g. INT/QA/UAT/STAGE/PROD.

No Geolocation data on first request

Sitecore Geolocation works asynchronously, due to that at times you might not see geolocation data on first request/for new IP, Which is not in cache.

Sitecore GeoIP logic
Geolocation flow (Image Courtesy : https://www.brimit.com/blog/sitecore-geoip-geolocation-module-how-it-works )

Sitecore community has few solutions for this challenge:

  1. https://kb.sitecore.net/articles/320734 : Here solution1 uses delay logic — Which personally, I would like to avoid for heavy traffic website. Solution2 suggests using Custom provider.
  2. https://www.brimit.com/blog/sitecore-geoip-geolocation-module-how-it-works : Brimit team, has done a great job and created Fallback module. Which seems derived from Solution2 suggested in last article. We’ve used this for one of our client — And it’s working fine!
  3. https://www.redmoon.london/sitecore-ip-geolocation-service-resolving-geoip-information-on-the-first-request-using-circuit-breaker-design-pattern/ : Recently came to know about this approach — Which is using Circuit breaker approach. I haven’t personally tried this. But good to explore.

How to troubleshoot?

Sitecore geolocation works fine in lower environments. But as soon as you go on higher environments, you start noticing that it doesn’t work. Few of the reasons behind that are:

  1. Application Gateway
  2. Load balancer
  3. Reverse proxy
  4. Corporate Proxy
  5. Firewall

Your Production environment will have either/all of the above things and they might cause trouble in overall working mechanism of Geolocation.

For any troubleshooting you need right tools. Let me share few of those:

  • https://kb.sitecore.net/articles/798498 : Sitecore has done good job documenting all the steps. Especially TestIP.aspx page. Use this to do quick test of geolocation configuration.
  • https://gist.github.com/klpatil/d4c5d242b715ac8c6213366e85be585c : I have also created GeoLocation Test page, which prints Geolocation information, all request headers. Here, you need to closely observe — X-Forwarded-For header. It should have Client’s IP address. How to check that?
    • Open https://www.whatismyip.com/ and take a note of IPV4 address.
    • Now. Open GeolocationTest page and IPV4 address should be value for X-Forwarded-For header. If it’s not – Then something is not rightly configured.

Let’s understand about each possibility and solution:

This image depicts this challenge nicely (Image Courtesy : https://mikael.com/2018/09/sitecore-x-forwarded-for-handling/)

Hope this helped, Have I missed scenario which you faced? Please share, I will amend it in this post.

Happy Geo-locating! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: