Blocking of third-party cookies

How to block third-party cookies?

Nelson
Written by NelsonLast update 2 months ago

Third-party cookies are cookies set by a website other than the one you are currently visiting. While these cookies primarily track user activity across sites, it's important to understand that they are often placed by third-party scripts. These scripts can introduce, modify, or remove certain functionalities on your website, beyond simply setting cookies.

CookieScript uses advanced technologies that allow blocking any third-party scripts, even your custom scripts, without editing the actual third-party script code.

There are several ways to block these cookies or scripts: you can block them using Google Tag Manager or CookieScript, either automatically or manually. However, please note that using both Google Tag Manager and CookieScript together for blocking can result in duplicated cookie scanning sessions, which may slow down your site.

To ensure smooth functionality, we recommend selecting only one method to manage third-party cookies and scripts on your site:

  1. If you are using Google Tag Manager: Avoid enabling the CookieScript automatic script-blocking feature for scripts already managed by Google Tag Manager.

  2. If you are using CookieScript to block scripts: Google Tag Manager should be disabled for third-party cookie blocking to prevent conflicts.

Note: CookieScript does not block third-party cookies by default. You need to configure your banner settings first, choosing one of the methods mentioned below.

A guide on how to block third-party cookies using Google Tag Manager is here.

A guide on how to block third-party cookies manually with Javascript is here.

A guide on how to block third-party cookies using CookieScript (automatically or manually) is presented below.

Automatic third-party cookie blocking using CookieScript

CookieScript uses advanced technologies that allow blocking any third-party scripts, even your custom scripts, without editing actual third-party script code.

How does it work under the hood? Automatic third-party cookies blocking consist of three steps:

  1. Cookie scanning

  2. Cookie categorizing

  3. Third-party cookies blocking.

Scanning

During the scanning process, Cookie Scanner scans all scripts used on your website. The Cookie Scanner is smart enough to distinguish similar scripts from unique ones and treats similar scripts as one script.

Categorizing

All scripts found during the scanning process are then listed in the Scripts tab of your CookieScript dashboard. Here you can choose manually what scripts should be blocked by CookieScript until the user agrees to a certain category of cookies.

Blocking

The CookieScript banner is loaded and starts looking through other third-party scripts. At this point the banner "knows" what scripts should be blocked before it gets loaded. When such a script is found, the type for the script is changed and the script is not loaded/executed.

Note: In order for this to work properly, the CookieScript code should be included before third-party scripts that should be blocked automatically. Ideally, the CookieScript code should be the first script included on the website.

To block automatically existing third-party scripts, you should enable the automatic third-party cookie blocking feature on CookieScript:

  1. Go to editing your Cookie Banner Item and select the Scripts section.

  2. Find a script that sets third-party Cookies, for example, the Facebook Pixel script.

  3. Choose a Cookie Category after accepting which script should be activated. Let's say mark it as a Targeting category. Mark script to be blocked and save your changes.

Easy as that. Your Facebook Pixel script will now be deactivated until the user agrees to the Targeting Cookies.

There are a few requirements for Automatic third-party cookie blocking using CookieScript to work properly:

  1. The CookieScript-generated code must come before any other script that should be blocked. Otherwise, it won't be able to block those scripts.

  2. The whole functionality should be enabled in settings, it can be found in the Scripts section of your banner.

  3. You might need to re-scan your website in case the last scan was completed before this functionality was enabled.

  4. In the case of a remote script, the automatically blocked script will not be executed, but the request for the script will still be sent to the server. 

Note: Due to the technical limitations of modern browsers, it is only possible to block cookies that are set during the JavaScript execution. Cookies that are set by the server during the response (with an HTTP header) cannot be blocked automatically. Although this is rarely the case, if you have such scripts, you have to block such scripts manually using Javascript.

Automatic third-party cookies blocking in included in Standard and Plus pricing plans.

Read more about:

Automatic third-party cookies blocking.

How to Block Third-Party Cookies?

Did this answer your question?