Ralf Schmitz Bongiolo

July 29, 2021

How to opt-out of Google's FLoC aberration on Rails

TLDR:
# add to the end of your config/application.rb
config.action_dispatch.default_headers = config.action_dispatch.default_headers.merge(
  "Permissions-Policy" => "interest-cohort=()"
)

Plausible has a really good article on what is FLoC and why you might want to opt-out on your site and as a user, you can read it here. But basically, it's a way to track you directly on the browser level, without the need for third-party cookies (which probably are going to be disabled on most browsers), Google Analytics or such.

There's an open PR on Rails (here) that adds the `Permissions-Policy` headers and would also allow configuration of the `interest-cohort` value. Currently, Rails has a `permissions_policy` configuration method, but it generates a `Feature-Policy` header, this header was renamed to `Permissions-Policy` and is not supported by all browsers yet, there are more details on the linked PR discussion.