Implementation

Automatic and manual blocking

How the two blocking modes differ, when to choose manual mode and how to mark scripts correctly.

6 min read

The blocking mode decides which scripts we hold back until the visitor gives consent. In automatic mode we block all tracking scripts detected on the basis of a scan of your site; in manual mode, only those that you mark yourself in the page code. Below you'll find a comparison of the two modes, the conditions they work under, and instructions for marking scripts.

How do the two modes differ?

ModeWhat we blockWhat it requires from you
Automaticall detected tracking scripts, based on a scan of the sitethe main CookieOfficer code placed as the first script in <head>
Manualonly scripts marked with the data-co-cat attributemarking every script by hand in the page code or in Google Tag Manager

You can choose the cookie blocking mode in two places in the panel: on the Installation page, in the “Deployment settings” card after clicking “Change settings”, or in Settings, in the “Cookie blocking” section. A change affects the specific project it is made in.

When should I choose automatic cookie blocking mode?

This is the default setting and is sufficient for most setups. Choose it when you add the CookieOfficer script directly to the source code of your website, in the <head> section, before Google Tag Manager and before the other tools.

Automatic cookie blocking has some limitations worth knowing about:

  • It doesn't work when CookieOfficer is set up through Google Tag Manager. Our code then loads asynchronously (just like GTM), so scripts added directly to the page may run earlier. In that case, you should control when the tags in your GTM container fire from within GTM itself.
  • We don't block cookies and trackers that are marked as Unclassified. Until they are assigned a category, we deliberately let them through so as not to break how the site works. Fill in the categories on the Cookies page.
  • We don't block cookies and scripts from your own domain. This protects the shopping cart, login and search on your site from being stopped by accident.

When should I choose manual cookie blocking mode?

We recommend using this mode in the following situations:

  • when the CookieOfficer code can't be added first in the <head> section,
  • when you want full control over what is held back, or
  • when automatic blocking stops a script that the site needs in order to work.

In manual mode we block only scripts marked with the data-co-cat attribute. An unmarked tracker will run before the visitor gives consent, so each one has to be marked separately. After you choose this mode, the panel reminds you of this with a yellow message on the Installation page, on the Settings page and in the review of changes before publishing.

How do I mark a script with the data-co-cat attribute for manual blocking?

You hold a script back by making two changes at once:

  1. Change type="text/javascript" to type="text/plain".
  2. Add data-co-cat with the category name.
<script type="text/plain" data-co-cat="analytics" src="…"></script>

The attribute alone isn't enough. Without type="text/plain", the browser will run the script before it is stopped.

Mark the script you want to block with the appropriate category. Use the following keys:

  • necessary for Necessary,
  • analytics for Analytics,
  • marketing for Marketing,
  • personalization for Functional.

A wrong value will block the script permanently, and the panel won't show any information about it.

How do I mark an iframe or an advertising pixel?

You mark iframes, images and stylesheets differently from scripts. They have no off switch in the form of the type attribute, so the only way to stop them from loading isn't to give them the URL.

You enter the URL along with the data-co-src attribute. It will be loaded once the visitor has given consent.

<iframe data-co-cat="marketing" data-co-src="https://www.youtube.com/embed/…"></iframe>

Keep in mind:

  • Blocking works on every page element except script. So it also covers img images and link stylesheets.
  • Enter the file address in data-co-src. After the visitor gives consent, we'll move it to where it normally goes: for frames and images, into src; for stylesheets, into href.
  • After unblocking, the element gets the data-co-unblocked attribute with the category name. You can check this in the page code. If the attribute is missing, the element is still waiting to load.

Fallback unblocking of scripts in manual mode

Choosing manual script blocking and marking scripts with the data-co-cat attribute means that they are run exclusively by our code. If the CookieOfficer code doesn't load on the page, the scripts will be blocked. In that case, some elements such as chat, maps and video may not load. The cause may be a network block or an ad-blocking extension in the visitor's browser.

Fallback unblocking is additional code that will run the marked scripts if our main code doesn't load. To add it, copy a few lines from the “Gating scripts manually with data-co-cat? Add the fallback block” section on the Installation page. Replace your current code with them; don't add them alongside the existing code.

In automatic mode, fallback unblocking isn't needed. Without our code, scripts aren't blocked, so there's no need to restore them.

How do I check that the markings for manual mode work correctly?

Run a scan of your site and go to the Cookies page. If the scan finished successfully and no message about trackers running after the visitor rejected consent appeared above the list, the markings worked.

Common mistakes to avoid

  • Don't leave type="text/javascript" in place when you add the attribute. The script will run before the visitor gives consent, while you believe it has been held back.
  • Don't enter Polish category names. The marked element will be blocked permanently.
  • Don't rely on automatic mode when you set up through Google Tag Manager. Control when tags fire, based on the visitor's consent, in GTM, and mark scripts in the page code with the attribute.

Didn't find an answer?

Write to us. We reply on working days, usually the same day.

Contact us