Possible Solution: No provider information when using AnonymizeIP

Sorry for double posting. I accidently posted in the wrong section before:

I hope this issue has not been solved before. At least the thread i read let it unsolved or where even closed.

I found a solution which at least works for me quite well. I am obfuscating the last octet of the IP adress and have not tested if it also works when 2 octets are replaced by a 0.

The provider is determined by a php function called gethostbyaddr. It determines a hostname by an ip-adress. Big internet service providers normally have many adresses so you can assume all 255 possibilities of the last octet belong to the same provider. The only adress that normally isn’t used (as it is used for other means in the IP protocol) ist that one with a 0. My solution is not to replace the last octet with a 0 but with a 1.

Only one line of code has to be changed for that. In /plugins/AnonymizeIP/AnonymizeIP.php i replaced $ip[–$i] = chr(0); (in “applyIPMask”) with $ip[–$i] = chr(1); .

I have no idea if that works in every case. For a few tests I was able to make it worked perfectly well.

Perhapse that could be a good solution for some of you.

Thanks for the suggestion. Created a ticket in: When anonimize IP is enabled, consider doing Provider / GeoIP lookup faking the last IP byte to 1 ? · Issue #3023 · matomo-org/matomo · GitHub to discuss this possibility.

What about saving all IP relevance Data like Provider and Geo Data befor anonymize the IP?
Edit: Forget it. Just found that this was changed due to privacy reasons. But i don’t understand why. You can’t connect an anonymized IP with a whole country. Or a provider.

would also like to see this changed in an upcoming version as ip lookup won’t work the way it is right now …
And as winfel said - you can safely assume that 99% of the IP addresses are correct with 1 on the end … because /25 (or smaller) subnets won’t be spread over 2 countries …


Good news: GeoIP is now integrated in Piwik, enabling Accurate Visitors Geolocation in your Analytics reports. To enable GeoIP go to the Settings > Geolocation admin page, and follow the short instructions.

You can also get an even more accurate Country & City Database from here to enjoy top accuracy in detecting your visitors locations.

See also the documentation about Geolocation - Analytics Reports in Piwik.