JavaScript
Any site
npm install no-thanks.js, or from a CDN: https://cdn.jsdelivr.net/npm/no-thanks.js/dist/no-thanks.js and .css. With several purposes, use no-thanks-purposes.js and .css.
<link rel="stylesheet" href="dist/no-thanks.css">
<script>
window.noThanksConfig = {
revision: '1',
purposes: [
{ id: 'audience', label: 'Audience measurement', description: 'Google Analytics' },
{ id: 'videos', label: 'Videos' },
],
texts: { message: 'This site would like to measure its audience. Is that OK?' },
};
</script>
<script src="dist/no-thanks.js" defer></script>
<template data-no-thanks="audience">
<!-- the tracker's code, as given; no value: needs every purpose -->
</template>
<a href="#no-thanks">Cookies</a>
- revision
- Change it to ask every visitor again.
- maxAge
- Days the choice is kept, 182 by default.
- cookies
- Cookie name prefixes deleted on refusal.
- privacyUrl
- Adds a « Learn more » link after the message.
- purposes
[{ id, label, description }], optional.
- texts
- Every text of the banner:
message and dnt are HTML, {date} is replaced in the reminders.
- buttonClass
- An extra class on the banner's buttons.