How to Stop Tracking in WP Statistics with PHP code?

Sometimes you need to enable the Anonymize IP Addresses with PHP code for GDPR. Here is an example to do that.

add_action('init', function (){
global $WP_Statistics;
$WP_Statistics->update_option( 'anonymize_ips', '1' );
});

Mostafa
Mostafa
Love working with WordPress, Laravel, and e-commerce platforms—basically anything that lets me create, innovate, and automate. Always up for a challenge, whether it’s in code or on the road.
Let’s get started
Take your business to next level

Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.