0

Using XP 10.1 & the GeoIp service.
I would like to get the Postal code of the visitor to execute some business logic and this is not for Personalization.

With the following code, I am able to get the latitude, longitude and the Country name, but all the other properties are null.

var latitude = Sitecore.Analytics.Tracker.Current.Interaction.GeoData.Latitude.GetValueOrDefault(0);
var longitude = Sitecore.Analytics.Tracker.Current.Interaction.GeoData.Longitude.GetValueOrDefault(0);
var contactLocation = Sitecore.Analytics.Tracker.Current.Interaction.GeoData;

Is it possible to get the postal code with GeoIp service.

1
1

The data is definitely there. But the IP you are current using, Sitecore does not have the granular data for it. Try from a different IP.

"GeoData": {
  "AreaCode": "N/A",
  "BusinessName": "Comcast Cable",
  "City": "Shelburne",
  "Country": "US",
  "Dns": "comcast.net",
  "Isp": "Comcast Cable",
  "Latitude": 44.2923,
  "Longitude": -73.3148,
  "MetroCode": "523",
  "PostalCode": "05482",
  "Region": "VT",
  "Url": "N/A"
},

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.