Serve cookie consent banner to EU visitors with Cloudflare Workers 🌩
Cookie Choice is a endpoint that serves a JS library for rendering a cookie consent banner. Endpoint is a Cloudflare Worker to take advantage of the geolocation.
npm ci
npx rollup -c
cloudflare-worker.js
to Cloudflare Workers.const privacyPolicyLink = "https://my.privacy.policy/";
const force = true;
const {
renderCookieChoice
} = await import(`https://my.cloudflare.worker/cookie-choice.js?privacy-policy-link=${privacyPolicyLink}&force=${force}`);
renderCookieChoice();
document.body.addEventListener(
"cookieChoice:accept",
{
once: true
},
() => {
console.log("Thanks for the cookies!");
}
);