Block scripts and show the cookie list
Block a script until consent
Section titled “Block a script until consent”Change the script’s type to text/plain and add the category it belongs to:
<!-- Before --><script src="https://example-analytics.com/tag.js"></script>
<!-- After: runs only once the visitor allows statistics --><script type="text/plain" data-cookiedoo-category="statistics" src="https://example-analytics.com/tag.js"></script>Inline scripts work the same way:
<script type="text/plain" data-cookiedoo-category="marketing"> // runs only after consent for marketing</script>| Category | Use it for |
|---|---|
preferences |
Remembering choices such as language or region |
statistics |
Analytics and measurement |
marketing |
Advertising, retargeting, social media pixels |
Necessary scripts need no change. When the visitor agrees, CookieDoo turns each blocked script into a normal one, keeping its other attributes. If a visitor later withdraws consent for a category whose scripts already ran, the page reloads, because a script that has run cannot be unloaded.
Cookies set by scripts you cannot change
Section titled “Cookies set by scripts you cannot change”CookieDoo also watches cookie writes in the browser. Cookies that belong to a category without consent, according to your cookie declaration, are removed. This is why it matters that the scan knows your cookies, and why the snippet must load first.
Cookies set by your server (Set-Cookie headers) cannot be stopped from the browser; set only necessary cookies on the server, or check consent there.
Show the cookie declaration
Section titled “Show the cookie declaration”Put this element where the list should appear, usually on your cookie or privacy policy page:
<div id="CookieDooTableData"></div>CookieDoo fills it with a table of your cookies by category, name, provider, expiry and description, in the visitor’s language. It always shows your current cookie declaration, which the scan keeps up to date.