0

Using 8.2, trying to use Geolocation Service in my code to get data about the user's location:

var geoData = Tracker.Current.Session.Interaction.GeoData;

geoData is not null, however every property is being returned as N/A (state = "N/A", country = "N/A", etc).

I've logged into the Geolocation service in Sitecore through the App Center, and in the experience editor, it shows that the service is working. I double checked that in Sitecore.xdb.config, I have:

  • Xdb.Enabled = true
  • Xdb.Tracking.Enabled = true

EDIT:

So, Geolocation is working, but I've found the issue is that the user IP (from Tracker.Current.Session.Interaction.IP) is 127.0.0.1 (localhost) which is why it's not returning location data

  • Do you have proxy server? – x3mxray Jun 11 at 15:53
  • And has it been running a long time without GeoIP working? All those N/A records will remain. – Mark Cassidy Jun 11 at 19:46
  • So, I fee it prudent to mention that your update makes this question a candidate for closure. I would remove the "Update" portion of this question, and then mark an answer as accepted or create an answer. Then your other question will be ok. As it is, this is now a dupe of your follow on question. – Pete Navarra Jun 12 at 15:26
2

You should set X-Forwarded-For header in config settings:

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

If you use reverse proxy server you should also disable "Include TCP port from client IP" in Application Request Routing enter image description here

1

For anyone else having this issue--

It was necessary to set this property in Sitecore.Analytics.Tracking.config:

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

However, the issue with my local site was not a load balancer, which the X-Forwarded-For setting will help with (and was necessary for my solution on production). The issue is that because I'm hitting my local site locally, it's expected that my IP is going to show up as 127.0.0.1, and I do not have the X-Forwarded-For header in my request as I am not on a load balancer. The issue is that I needed to test whether the Geolocation code I wrote was actually working, so in order to test it locally, I used the Sitecore Analytics Testing Tools, which allows me to set the X-Forwarded-For header in my requests. With that in place as well as the config update, Tracker.Current.Session.Interaction.Ip now returns the IP that I specified in the Analytics Testing Tools.

As an additional step, if your site is on a load balancer, it is necessary to configure the load balancer to return the X-Forwarded-For header. The name of this header might be different depending on the load balancer (Akamai uses "True-Client-IP")-- whatever the header is called is what you need to use in the config.

0

Follow below steps to check if GeoIP is enabled and working fine.

Solution 3 of below article has a link to download TestIp.aspx file. https://kb.sitecore.net/articles/798498

  1. Save the TestIp.aspx file into the /sitecore folder
  2. Open the http://hostname/sitecore/TestIp.aspx page;
  3. Enter any known IP address into the text box and select "GetInformationByIp".
  • So, Geolocation is working, but I've found the issue is that the user IP (from Tracker.Current.Session.Interaction.IP) is 127.0.0.1 (localhost) – Erica Stockwell-Alpert Jun 12 at 14:06

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.