PHP- Can I determine visiting user's country (by IP-address) with Piwik's API?

Is it possible determine visiting user’s country (by IP-address), somehow with Piwik’s API? I have installed GeoIP and my site is build with PHP.

I need to know user’s country in beginning of my “index.php”.

I’m totally new with Piwik and I can’t find any documentation about this.
Thank you for your help! :slight_smile:

Hi Tronic,

Yes it is possible! Check out the API UserCountry.getLocationFromIP Reporting API Reference: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Thanks Matt! Is there any example somewhere how to use this API with PHP? I have try to find it 1 hour now and just can’t find it… :slight_smile:

See here
a tutorial Tutorial: Get your top 10 keywords: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3
a guide: Querying the Reporting API: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3