How to set PrivacyManager.ipAnonymizerEnabled via config.ini.php or PHP?


we want to prevent that any matomo-user (even the admin) changes the value of PrivacyManager.ipAnonymizerEnabled. So our idea was to set this setting either in the config.ini.php or in the PHP-code of our application.

We tried something like:
in the config.php.ini, but it seems to have no effect.

We found:
but couldn’t find any example or best-practice how to call this in PHP.

The only thing working so far is directly accessing the option-table in the database, which is always a kind of “rude”:
update matomo_option set option_value=1 where option_name=‘PrivacyManager.ipAnonymizerEnabled’

What is the recommended way to do this?

It seems this section is about privacy terms and conditions…
Then probably, as you wrote further, this value may be stored in the DB.

In my opinion, the best to do is:

  • prevent (in the code) the possibility to change this value
  • and/or shortcut the value read in the DB and always return true

But sorry, I am not expert at all in Matomo plugin making… Is the IP anonymization a class that is injected to Matomo? Then you could provide another class inherited from the base one…

PrivacyManager is a pre-installed plugin. So I would prefer a solution using this plugin “out of the box” (without changing it) since I assume that it will get developed further and updated in the future.

As you need to change the behavior of Privacy Manager, you’ll have to code something.
My suggestion was to create a new plugin that just overrides the access to the ipAnonymizerEnabled configuration value… If you change the code directly inside the Privacy Manager, it would be squeezed at next Matomo update…
Or else you can ask for a new feature request at:

Thanks again for your reply! Not sure this is “changing the behavior”, it’s just making sure that some settings are set in a certain way. We are deploying our software to a lot of systems in an automated way, so beside the error that someone clicks on the wrong checkbox by mistake we want to make sure as well that all the settings are like we want them to be without the need to open the matomo backend and check every time. It might be for example that matomo is changing some default-values in future versions for new installations.

So in our view it’s more a “configuration-thing” than a “behavior-thing”. Thats why I was asking for the correct way to set the settings.

This is the behavior of the configuration management :wink: