API Questions on Kentico API.
Version 5.x > API > Geolocation View modes: 
User avatar
Member
Member
jhart-theatomgroup - 6/24/2013 1:58:52 PM
   
Geolocation
Does Kentico V5.5 offer any API options for finding a page visitors location? I basically just want to check to see if a user is located outside of the US or not.

User avatar
Certified Developer 13
Certified Developer 13
Accepted solutionAccepted solution
kentico_josefd - 6/25/2013 8:02:46 AM
   
RE:Geolocation
Hello,

You can use the following:
CMS.WebAnalytics.IP2CountryHelper.GetCountryByIp(CMS.GlobalHelper.HTTPHelper.GetUserHostAddress());

Please let me know if it helps.

Regards,
Josef Dvorak

User avatar
Member
Member
jhart-theatomgroup - 6/25/2013 8:40:37 AM
   
RE:Geolocation
Precisely what I was looking for. Thanks.

User avatar
Member
Member
jhart-theatomgroup - 7/8/2013 9:37:18 AM
   
RE:Geolocation
I have been using this and it works but some US IP addresses are being flagged as being Canadian IPs. Is there any way I can resolve this?

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 7/9/2013 6:27:22 AM
   
RE:Geolocation
Hello,

there are two possible reasons why this is happening. The first issue is that the IP-2-Country library shipped with Kentico CMS v5 is outdated by now and the IP ownership may have changed since when it was released. Additionally, the IP-2-Country library is not always correct even when it has up to date information.

Downloading the latest release and replacing the default IP library should solve most of the problems when using CMS v5, but I would also recommend you to consider update to CMS v6, which uses proprietary geolocation library with much better precision.

The latest IP-2-Country release can be found here:
http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip

After downloading, rename the zip file to ip2country.dat and place it to the directory:
~/App_Data/CMSModules/WebAnalytics/IP2Country/

Regards,
Josef Dvorak