Articles on: Settings

Manual script blocking guide


While auto-blocking is a quick and easy way to prevent cookies from being set, there are several reasons to want to consider manually marking up script tags to prevent them from setting cookies prior to consent.

Manually blocking cookies has a far lesser impact on store performance and will prevent cookies from being set even if the Pandectes GDPR Compliance scripts fail to load.

There are also situations where auto-blocking is not a viable solution, as it impacts the store to an extent that requires so many adjustments that manually marking up becomes a lesser ordeal.

Using the data-cookiecategory attribute

In order to block a script, the markup uses two parts. The disabler prevents the script tag from loading and the enabler allows Pandectes GDPR Compliance to enable this script tag if the appropriate consent has been given.

The steps to make it happen are the following and work the same for inline scripts and for external script tags.

Set the type to "javascript/blocked".
As this tells the browser to regard the script as blocked javascript, this essentially disables the script.
Add the data-cookiecategory attribute and assign it one of these values: "functionality", "performance" or "targeting".
This attribute defines the condition under which Pandectes GDPR Compliance needs to enable and load the script.

An example of marking up a script:
The following is a basic inline script that sets a cookie named email:

<script type="text/javascript">
document.cookie = "; expires=Sun, 31 Dec 2023 12:00:00 UTC; path=/";

To mark up this script to require consent to cookies in the "functionality" category we make it like this:

<script type="javascript/blocked" data-cookiecategory="functionality">
document.cookie = "; expires=Sun, 31 Dec 2023 12:00:00 UTC; path=/";

The category may be one of the following: “functionality”, “performance”, and “targeting”. Setting the right category will ensure that the script will be unblocked once the visitor consents to the specified category.

The following is a basic script that loads externally:

<script type=”text/javascript” src=””></script>

To mark up this script to require consent to cookies in the "functionality" category you need to do it like this:

<script type="javascript/blocked" data-cookiecategory="functionality" src=""></script>

Video guide

Updated on: 27/05/2024

Was this article helpful?

Share your feedback


Thank you!