Disable Google's FLoC on Sinatra

August 2, 2021 โ€” Ulysse

Googleโ€™s new technology, FLoC, is quite intrusive according to the EFF. Hence I strongly suggest against, as already it is disabled by Wordpress (2/5 of the web), and in discussion to be disabled by default on Rails.

To do disable FLoC for your users on Sinatra, it is quite easy:

before do
  # Disable google's intrusive FLoC.
  # See:
  # - [TL;DR](https://andycroll.com/ruby/opt-out-of-google-floc-tracking-in-rails/)
  # - [No link to analytics](https://usefathom.com/blog/google-floc)
  # - [main reference](https://amifloced.org/)
  headers "Permissions-Policy" => "interest-cohort=()"
end