Website Guider

The Ultimate Resource for WPadmins and Geeks

How To Disable Google’s FLoC in WordPress

Many of you may have heard about Google’s recent statement about tracking users for ad purposes. Various parties, such as DuckDuckGo, Brave, and others, have not approved this new type of tracking technology.

With the use of machine learning, Google will begin tracking users. They will track users using a new and modern method called FLoC rather than third-party cookies (Federated Learning of Cohorts). Let me help you out in understanding it.

What Does FloC mean and How It Impacts Users?

As previously stated, it is a new tracking method for tracking internet users. It is a completely machine-learning-based alternative to third-party cookies. FLoC will study users anonymously and categorize them into ‘cohorts’ in order to serve ads based on cohorts.

Google will not stop tracking you by implementing this system, but it will study you without the use of third-party cookies and, more worryingly, ‘anonymously.’ Different companies have raised questions like DuckDuckGo, Brave, etc.

If you are among the men who aren’t viewing this change positively, you can easily block this feature by doing a few tweaks. Let’s see how we can disable Google’s FLoC in WordPress.

How To Disable/Block FLoC In WordPress?

The basic way to avoid being tracked on this new system is to not use Chrome and use a privacy-focused browser.

Also, the website owners can also keep their web servers out of this by opting out of it. It can be done in many ways. Let’s find out how it can be done?

Adding Header in functions.php file

The first and easiest way to avoid participating in FLoC is to add the Header. You can copy the below code and add it to the end of the functions.php file.

add_filter( 'wp_headers', 'wg_disable_floc' );
function wg_disable_floc( $headers ) {
    if ( empty( $headers['Permissions-Policy'] ) ) {
	$headers['Permissions-Policy'] = 'interest-cohort=()';
    } elseif ( ! empty( $headers['Permissions-Policy'] ) && false === strpos( $headers['Permissions-Policy'], 'interest-cohort' ) ) {
	$headers['Permissions-Policy'] .= ', interest-cohort=()';
    }
    return $headers;
    }

Once done, hit save and sit back.

Adding Header through .htaccess

Headers can be set also by the Apache configuration file. You can add the following directive in .htaccess file.

<IfModule mod_headers.c>
  Header always set Permissions-Policy: interest-cohort=()
</IfModule>

Adding Header Through NGINX Config File

If your website runs on an NGINX web server, then you have to add this directive to the config file.

server {
    location / {
      add_header Permissions-Policy interest-cohort=();
    ...
    }
}

Remember, if you use only one config file for various websites, be sure to add the directive to each server block.

Conclusion

These were the easiest methods to disable FLoC in WordPress without a plugin. Now, it is your turn. What is your opinion regarding FLoC?

Please let me know in the comments section. I hope you liked the tutorial, be sure to share the article with your mates.

Raashid Din Dar

Raashid Din Dar is a web developer and designer. He specialises in WordPress Theme and Plugin development. Also, Web Designing is what he loves.He loves to read books and play with friends.

One thought on “How To Disable Google’s FLoC in WordPress

  1. Since FLOC is basically a replacement for 3rd-party cookies, which I’ve despised as a user AND website owner, my opinion is pretty much a given. But from a user’s perspective, entries in headers is pretty much a “suggestion” kind of like that robots.txt file. To ENFORCE this NOT being used, time to switch to DuckDuckGo instead of Google, and if you MUST use a Chromium derivative (Chrome is just a spin-off of the latter), use Brave instead and you’ll have pretty much all the same features except for custom plugins.

    I only recently became aware of this as an issue with a fresh install of the JOOMLA blogging software. One of the messages waiting for me when I logged in as administrator is that Joomla automatically enables the FLOC-disabling header by default.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top