Automatic blocking
The services declared in Cookies & services are recognised by the address of their scripts and iframes (136 services known in the catalogue). They are held as long as the visitor has not accepted their category, then run as soon as they accept.
You do not need to change your code for Google Analytics, Meta Pixel, Hotjar, Microsoft Clarity, LinkedIn, TikTok and other common tools: they only need to be declared, which the scanner’s Add all button does.
Manual blocking
For a script the catalogue does not know, change its type to text/plain and give its
category with data-cm-category: the browser does not run it, and Optooki runs it on
consent.
<!-- Runs only once analytics is accepted -->
<script type="text/plain" data-cm-category="analytics"
src="https://cdn.example.com/tracker.js"></script>
<!-- Also works for a script written in the page -->
<script type="text/plain" data-cm-category="marketing">
console.log('advertising accepted');
</script> The categories are:
| Value | Category |
|---|---|
necessary | Strictly necessary, always active |
preferences | Functional (language, chat, map…) |
analytics | Analytics |
marketing | Advertising and social media |
Videos and iframes
An embedded YouTube or Vimeo video sets cookies as soon as it shows. Replace src
with data-cm-src: the video is replaced by a placeholder that explains why it is
not shown, with a button to allow it, until consent.
<iframe data-cm-src="https://www.youtube.com/embed/ID"
data-cm-category="marketing" data-cm-service="youtube"
width="560" height="315"></iframe> The WordPress, PrestaShop, Magento, Joomla, Drupal and Contao plugins do this on their own for the YouTube and Vimeo videos in your content.
“Manage cookies” link
Visitors must be able to change their mind at any time, as easily as they chose. On top of the floating reopen button, add a link to your footer:
<!-- Opens the preference centre -->
<a href="#optooki">Manage cookies</a>
<!-- Or on any element -->
<button type="button" data-cm-open>Manage cookies</button>
<!-- Shows the banner again rather than the preferences -->
<button type="button" data-cm-open="banner">Review the banner</button>
A link to #optooki can also be created from the menu of most CMSs, without touching the
code: a menu item of type “custom link” or “URL”.
Cookie list
Your cookie policy must say which cookies are set, by whom and for how long. An element with the data-cm-cookie-list attribute shows that table, by category, from the declared services: it stays up to date with every
publication.
<div data-cm-cookie-list></div>
With the plugins, write the [optooki_cookie_list] tag in a page instead, and
[optooki_preferences] for a button that reopens the preferences. To react to consent
in your own code, see the JavaScript API.