0

I'm trying to use geolocation data in my code, and I found that the reason it isn't working is because the IP address in Tracker.Current.Session.Interaction.IP is returning as 127.0.0.1 (localhost, the site's IP address) instead of the IP of the client IP address. Using 8.2, and I'm not on a load balancer, I'm currently using a single instance on my local machine.

1

So you're accessing your own local instance of Sitecore from the same machine where the instance is deployed. That's why you're getting 127.0.0.1 as the IP, cause it's your local IP.

If you want to test GEO IP locally you should set the Analytics.ForwardedRequestHttpHeader setting:

<setting name="Analytics.ForwardedRequestHttpHeader" value="X-Forwarded-For" />

And add this header to your request using either some browser plugin for modificiation of the headers or tools like PostMan and set the value of the header to your chosen IP address that you want to test your Geo IP service with.

| improve this answer | |
  • I made that change, but what do I do now? I updated Analytics.ForwardedRequestHttpHeader in Sitecore.Analytics.Tracking.config, but I'm still seeing 127.0.0.1 in both Request.UserHostAddress and Tracker.Current.Session.Interaction.IP, and I checked the Request Headers and it does not have x-forwarded-for in the keys – Erica Stockwell-Alpert Jun 12 '19 at 14:26
  • 1
    Have you added header to your request? E.g. if you use chrome for testing you can use this extension: chrome.google.com/webstore/detail/modheader/… . Then you need to set that header value to some valid IP address which will be then used to resolve geo ip data – Marek Musielak Jun 12 '19 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.