Selecting different geolocation methods for browser tracking and API tracking

In my experience, MaxMind’s GeoIP2 (or even the free GeoLite2 database) provide more accurate geolocation data than both Matomo’s default method and the IP2Location database. Installing the Apache/NginX extension is a breeze and setting up the necessary environment variables on the server a matter of minutes.

However, the Matomo admin page clearly states that this method “can only be used with normal browser tracking” — not for tracking via API calls from a server app, for instance.

Is it, or would it be, possible to select different methods for browser tracking and API tracking? I would like to use MaxMind for browser tracking and IP2Location for the API calls.



This is weird as Matomo uses the Maxmind code and the normal maxmind or dbip databases for its default geolocation. So you should be able to give Matomo the same database as your webserver and it should give you the exact same result. Matomo just doesn’t use the free GeoLite2 database by default as it is no longer published under a free license but requires an account and api key.

Just in case this wasn’t obvious: The reason for this is that the Apache/Nginx extension can only geolocate the IP of the sender of the http request and if you would send tracking data from your application server you would only geolocate the server.

There is no core Matomo feature for this, but I think it should be possible to add a custom parameter to the API calls and then write a Matomo tracking plugin that selects the geolocation provider based on this parameter. But I can’t promise anything there.