Cookie Blocking

What are Third-Party cookies?

Third-party cookies are cookies set by websites that are outside of your current domain. They are mostly used to track users between websites and display more relevant ads on the domain.

For example, the cookies used by Facebook like-button on your domain, support chat functionality provided by a third-party service, and so on. Another example is an advertising service (ex: Google Ads) which also creates a third-party cookie to monitor which websites were visited by each user. This is the main technology used to show you the product ads that you previously searched for on a completely different website.

If you want your domain to comply with the latest regulations, such as CCPA and GDPR, you might want to block those third-party cookies unless the user specifically agreed to use them. This article explains how to establish cookie blocking using Cookie-Script as a cookie compliance solution.

Privacy Pillar provides Automatic Cookie Blocking, a special feature to block cookies at your website until the user gives consent through Privacy Pillar's cookie banner. With this feature, you can block the cookies of any category except essential cookies and when the user allows any categories through the cookie banner, the set cookies under those categories will be enabled.

When you configure the cookie banner, you can configure the automatic cookie blocking as follows:

  1. In Banner Configuration, under Advanced Features, enable Cookie Blocking.
  2. Select Auto and save your configuration.
  3. Now, in the side menu, click Auto Cookie Blocking.

    - The Auto Cookie Blocking page will appear. Switch to Available Tag tab on the page by clicking on it.
  4. A list of hosts appears in the cookie scan results.
  5.  You can add as many hosts as you want by clicking the "+" icon or by selecting multiple tags and then clicking on "Add Selected" button. 
    - By default, the status of all hosts shows DISABLED, which means tag blocking is disabled, and these hosts will appear on the website on the user side.
  6. After clicking on the "+" or "Add Selected" button all the selected tags will populate under the "Blocked Tags" section. Now, click on the "Blocked Tags" tab.
  7. Click right to the host that you want to block.
  8. Edit script popup appears. Choose a suitable category from the drop-down menu for the chosen host & select all the available parameters under the Dynamic Params dropdown. Additionally, you have the option to choose whether a host loads implicitly or explicitly for a certain regulation.
    Once the selection is done, click the Save button.

    Note:
    For CCPA & Global Regulation:
    Implicit: Without taking into account the user's permission, the host that is set as implicit will load first.
    Explicit: Before loading the host or script, the host that is selected to be explicit will need consent for the designated category.
     
    For GDPR & DPDPA Regulation:
    By default, the explicit method is applicable.
  9. After completing the configuration, click on the Go to Cookie Banner link to go to the Banner Configuration and Publish the banner.
For best results ensure that tags are loaded in the following order:
  1. Privacy Pillar CMP
  2. All the Blocked tags
Note:

You can block third-party cookies by blocking the whole third-party functionality. This means Google Analytics, Facebook buttons, AdSense, and anything else that you block won't work until the user agrees with cookie consent. You can manually achieve this in the following ways:

Blocking Third-Party Cookies Set with JavaScript

To block third-party cookies, find a JavaScript code that sets third-party cookies and follow the steps.

If all the cookies from a third-party script are assigned to a certain category, you should include that category in az-data-category attribute of the script.

The az-data-category attribute should have a value of the cookie category that this third-party JavaScript is assigned to. This means that whole third-party service cookies should be assigned to one of the following categories (which is usually the case). Possible category values are: 

All JavaScript with such attribute changes will only execute if the user agreed with the cookie policy.

Note: It is possible to assign third-party scripts to the above categories, this is helpful if the third-party script sets cookies from the categories and the user must agree to all cookie categories that are set by the script.

To use multiple categories, list them all, separated by a space. In this case, a third-party script will be included if the user agrees to all categories listed in the az-data-category attribute:

<script type="text/plain" az-data-category="funtional">

Example of Included JavaScript File

Change code from:

<script src="/js/myscript.js"></script>

Change code to:

<script type="text/plain" az-data-category="functional" az-data-src="/js/myscript.js"></script>

Blocking Third-Party Cookies Set with an iframe

To block third-party cookies set with iframe (like YouTube videos), find an iframe code that is setting third-party cookies and follow the steps.

All iframes with such attribute changes will only show up if the user agreed with the cookie policy.

Change code from:

<iframe  height="350" src="https://www.youtube.com/embed/xxxxxxxxx" frameborder="0" allowfullscreen></iframe>

Change code to:

<iframe  height="350" az-data-src="https://www.youtube.com/embed/xxxxxxxxx" alt="Please accept cookie policy first" az-data-category="functional" frameborder="0" allowfullscreen></iframe>

Blocking Images of third-party cookies

In the same manner, you can block image/object elements from setting third-party cookies.

Example of Image Element

Change code from:

<img src="http://example.com/image.jpg"/>

Change code to:

<img az-data-src="https://picsum.photos/200/300/?blur" az-data-category="functional"/>