This JS library contains my experiments around Google Chrome's Privacy Sandbox.
I have not yet decided which way this is going. Currently, it tries to bring some Privacy Sandbox APIs to unsupported browsers, such as Firefox, Safari or... Chrome :)
<script src='privacysandbox.min.js'></script>
npm install
#for starting Express server:
node server.js
#or, for development:
npm run serve
This implementation stores user browsing history in localStorage (only within one domain) and generates cohort_id using simhash algorithm.
After including privacysandbox.min.js
file on website, you can get cohort id of the user:
(async () => {
cohort = await PrivacySandbox.floc.interestCohort();
url = new URL("https://ads.example/getCreative");
url.searchParams.append("cohort", cohort);
creative = await fetch(url);
})();
You can replace (or initialize) FLoC API:
PrivacySandbox.floc.force();
You can also disable FLoC:
PrivacySandbox.floc.disable();
// or pass fixed cohort id:
PrivacySandbox.floc.disable('437737');