Skip to content


Get city, region, country name, lat/long, using via the API UserCountry.getGeolocation #3534

anonymous-piwik-user opened this Issue · 2 comments

3 participants


User request:

Would be great to add a feature where i can use the piwik API to get what country a user is coming from based on ip address: 


$url = ""; 
$url .= "?module=API&method=Actions.getCountry"; 
$url .= "&userIP=; 

$fetched = file_get_contents($url) 

But I think more generally there could be a simple API function that will be a proxy to the GeoIP provider currently in use. This could have many interesting uses. The function should check for: Piwik::checkUserHasSomeViewAccess()

Keywords: geolocation

Piwik Open Source Analytics member

All info should be returned for a given IP adress, and would return an array containing country/country_code/region/region_code/city/lat/long/etc.

Piwik Open Source Analytics member

(In [7494]) Fixes #3534, add UserCountry.getLocationFromIP method as proxy for GeoIP functionality.

@anonymous-piwik-user anonymous-piwik-user added this to the 1.10 - Piwik 1.10 milestone
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.