Geolocation Country DisplayName not resolving

Kurt Muller asked on January 23, 2018 14:03

I'm trying to print the current users country in an editable text webpart, but all I'm getting back is cms.country (0).

The macro string is: {% AnalyticsContext.CurrentGeoLocation.Country.DisplayName #%}

Any help please on this. I cannot find an answer in the other forums.

Thanks

Correct Answer

Trevor Fayas answered on January 23, 2018 14:16

First I would check if it can even detect the county. That object my be null. It needs a way to detect the county, which you need to set up first. Check the below link:

https://docs.kentico.com/k10/configuring-kentico/managing-sites/configuring-settings-for-sites/settings-on-line-marketing/settings-contact-management/settings-geolocation

1 votesVote for this answer Unmark Correct answer

Recent Answers


Kurt Muller answered on January 23, 2018 15:03

Thanks Trevor

I have definitely enabled geolocation tracking and the updated GeoLite City db is in place. Still cannot get the correct data.

I'm digging more, but cannot yet find the solution.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 23, 2018 15:06

Keep in mind that not all IP can be found, there are many cases where an IP cannot be resolved, I know from experience. So I would also see if this is always the case, what the IP address is, etc. Also any cdn networks can through this of, as the request comes from only a handful of places then unless it's configured to look for a different header Parameter with the original request IP.

0 votesVote for this answer Mark as a Correct answer

Kurt Muller answered on January 23, 2018 15:21

I had that in mind as well. Not sure how accurate some of these sites are, but I visited https://www.iplocation.net/ and that site is able to pick up my country based on my IP.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on January 23, 2018 15:25 (last edited on December 10, 2019 02:31)

Are you trying is to do this on localhost by any chance? Print your IP.

{% ip %}
{% AnalyticsContext.CurrentGeoLocation.Country.DisplayName |(identity)GlobalAdministrator%}

Google 'resolve ip to location' and see if your IP is getting resolved.

If

  • in the settings: On-line marketing > Contact management > Geolocation > General Enable contact geolocation by IP is checked
  • file \App_Data\CMSModules\WebAnalytics\MaxMind\GeoLiteCity.dat exists

it must work.

P.S. You can download monthly database updates from client portal: http://client.kentico.com/Download#GeoIP or from max mind.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on January 23, 2018 15:27

It may have a more up to date database, can you open the IP geolocate data file and see if you're IP is somewhere in that range? Trying to think if there is an easy way to verify first if any IP works and yours is just an found. May be able to with the API

CMS.webanalytics.geoiphelper.getcountrybyip

(From phone so make sure to properly capitalize). Try using that API on a test page and pass it some ips and see if you can get one to resolve at all.

0 votesVote for this answer Mark as a Correct answer

Kurt Muller answered on January 25, 2018 15:26

Hi guys,

I tested this morning, without changing anything and it's working. Trevor, thank you very much for your effort especially.

I have a feeling it's got to do with out office setup.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.