How to block Third-Party cookies using Mandatly Cookie Compliance solution

Let’s Understand what is third party cookie blocking?

Third-party cookie blocking is a vital component of safeguarding your online privacy. It involves the process of preventing websites from storing third-party cookies on your browser, thereby limiting tracking and data collection by external entities. By disabling third-party cookies, users can control the information shared with advertisers and other organizations across different websites.

What is Third-Party Cookie?

A third-party cookie is placed on a website by anyone (service partners, advertisers, etc.) other than the owner and collects user data for the third party. In other words, third-party cookies are set by a domain name that is not the one that appears in your browser address bar.

Website owners use them to track website visitors, improve the user experience, and collect data that helps them target ads to the right audiences. Third parties cookies are placed on a website by adding scripts or tags.

For example, if you visited a website and viewed specific clothing, a cookie might be placed in your browser. When you later visit any social media website such as Facebook, the third-party cookie shows you the ads for that clothing on a social media website.

To enhance online privacy, many users choose to block third-party cookies, minimizing tracking by external entities while browsing the web

Concerns with Third-Party cookies

Consumers are concerned about their privacy with third-party cookies. They can allow companies to track every website they visited; marketers collect a lot of data about them, which can be very uncomfortable for consumers, especially since almost anyone can access this data.

Many data privacy management software companies often point out that users can enable or disable third-party cookies depending on the level of their concerns and their personal preferences. It is vital to block the third-party cookies based on the visitor’s preference and not place third-party cookies on their computers.

The companies cannot comply with the data privacy regulatory requirements if you have a cookie consent banner on your website but not blocking third-party cookies based on consumer preference to use the cookies sensibly.

As a publisher, it’s essential to adjust to shifts in online privacy. Visitors generally block third-party cookies, enabling us to understand how to distribute content to our audience while respecting their privacy preferences

How Mandatly helps you block Third-party Cookies?

Mandatly Cookie Compliance Solution can automatically block cookies on your website until users consent. All the major third-party scripts used on a website are detected by our solution, and their cookies are prevented from being set.

How to block third-party cookies is a common question among internet users seeking to protect their online privacy and reduce tracking from external websites.

Follow the below mentioned steps to implement Cookie Banner for your website:

  • Go to Cookie Compliance -> Websites
  • Add your website domain
  • Copy the Script and insert it in your website HTML code

This code should be inserted in the header (section) of your website as the first Script before all other scripts. Code should be inserted on every page where the banner should be shown. It is important to load this banner before any other script so that the auto-block functionality works.

How Mandtly helps you block Third-party Cookies - Mandatly Inc.

For the cookies not blocked automatically, you can go either of the following way:

  1. Tag the Third-Party Script
    Block third-party cookies by tagging the third-party scripts to custom events on your website.
  2. Blocking third-party Cookies using GTM
    Block third party cookies by using the Mandatly events integrated with the Google Tag Manager.
  3. Add Source URL to relevant Third-Party Cookies
    Block third-party cookies automatically using Mandatly’s Cookie Compliance Solution.

1. Tag the Third-Party Script

Block the whole third-party functionality for blocking the third-party cookies. This means that Google Analytics / YouTube videos / Facebook buttons / AdSense or anything else you have blocked will not work until the user agrees with the cookie policy.

Find your JavaScript code that sets the third-party cookies and change the following points:

  • Replace the type attribute “text/javascript” to “text/plain”. (If the type attribute is missing, add it)
  • Now add the data category attribute and set it to the respective category Id or category internal name from the list of cookie categories <mandatlydata-cookiecategoryid=”ID”> or <mandatlydata-cookiecategoryname=”Category internal name”>
    • You can find a cookie’s category Id or category internal name from Cookie Compliance -> Configuration -> Categories -> Cookie category grid.
    • You can also find a cookie’s category Id or category internal name from Cookie Compliance -> Websites -> Add/Edit -> Categories tab
Blocking third party cookies manually - Mandatly Inc.

JavaScript code with the above changes will now respond to the user’s consent in real-time, without refreshing the page.

After following these steps for all third-party code on your page, you have finished blocking third-party cookies manually.

Below is an example of these changes in the Google analytics script.

Google Analytics script example:

Original script:

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview');
</script>

Change this to:

<script type="text/plain" mandatlydata-cookiecategoryid="ID">
or
<script type="text/plain" mandatlydata-cookiecategoryname="Category internal name">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-X', 'auto');
ga('send', 'pageview');
</script>

Note:
Manual Blocking Script option needs to be enabled while using the Custom tags, Custom events or GTM events on your website.

To enable the Manual Blocking Script option in your Mandatly account:
Navigate to Websites -> Edit website -> More Settings and turn on the Manual Blocking Script option.
Block the third-party cookies set by iframe, image, embed or link present on the website

Follow the below mentioned steps:

  1. Go to the code of iframe, image, embed or link that is setting the third-party cookies.
  2. Change the src attribute to data-src (For link, change the href attribute to data-href).
  3. Now add the data category attribute and set it to the respective category Id from the list of cookie categories <mandatlydata-cookiecategoryid=”ID”>.
a. Example for iframe element:

Original script:

<iframe width="560" height="315" src="https://www.youtube.com/embed/xxxxx" title="YouTube video player" frameborder="0" allowfullscreen></iframe>

Change this to:

<iframe width="560" height="315" data-src=https://www.youtube.com/embed/xxxxx” title="YouTube video player" mandatlydata-cookiecategoryid="ID" frameborder="0" allowfullscreen></iframe>
b. Example for Image element:

Original script:

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

Change this to:

<img data-src="http://example.com/sampleimage.jpg" mandatlydata-cookiecategoryid="ID"/>
c. Example for embed element:

Original script:

<embed type="image/jpg" src=”http://example.com/sampleimage.jpg” />

Change this to:

<embed type="image/jpg" data-src="http://example.com/sampleimage.jpg” mandatlydata-cookiecategoryid="ID"/>
d. Example for Link:

Original script:

<link href="http://fonts.googleapis.com/css?family= Lato:100" rel="stylesheet" type="text/css">

Change this to:

<link data-href="http://fonts.googleapis.com/css?family=Lato:100" mandatlydata-cookiecategoryid="ID" rel="stylesheet" type="text/css">

2. Blocking third-party cookies using GTM

If you are using Google Tag Manager (GTM) to insert certain third-party cookies on your website, you can implement GTM with Mandatly’s Cookie Compliance Solutions to control those cookies’ behavior.

Mandatly has pre-configured events which can be easily integrated with GTM based on Cookie Category ID. Mandatly events are fired for all the website pages with the banner.

Let us walk through an example of implementing the Google Analytics tag:

I. Add Mandatly Consent Banner code on GTM

II. Create Trigger:

Go to the Triggers and add a new trigger; the following page will be displayed. Click on the “Choose a trigger type to begin” and add a “Custom Event”.

Blocking third party cookies using GTM - Mandatly Inc.

To implement GTM with Mandatly Solutions, name the event as “MandatlyDataCategory-0003” 0003 suggests the Cookie Category Id.

Suppose 0003 is the Cookie Category Id for Analysis Category, so this tag will be fired when the user sets the Analysis category as Active and consents to the banner.

Replace 0003 with the Cookie Category Id you want to fire.

Blocking third party cookies using GTM - Mandatly Inc.

Click on the “Save” and name the trigger.

Blocking third party cookies using GTM - Mandatly Inc.
Blocking third party cookies using GTM - Mandatly Inc.

III. Implement Trigger:

Go to the Tags section and open a Tag created by you.

Click on the “Choose a trigger to make this tag fire” and select the trigger created by you.

Blocking third party cookies using GTM - Mandatly Inc.

Click on the “Save” button.

Blocking third party cookies using GTM - Mandatly Inc.

Click on the “Submit” button and publish it.

Blocking third party cookies using GTM - Mandatly Inc.

With this, you have successfully implemented GTM with Mandatly’s Cookie Compliance Solution. The google analytics cookies will load after the user sets the “Analysis category” on the banner as “Active” and consents to the banner.

Note:
Manual Blocking Script option needs to be enabled while using the Custom tags, Custom events or GTM events on your website.

To enable the Manual Blocking Script option in your Mandatly account:
Navigate to Websites -> Edit website -> More Settings and turn on the Manual Blocking Script option.

3. Add Source URL to relevant Third-Party Cookies

For blocking the scripts placing cookies before obtaining consent, follow the following steps:

  • Go to Websites -> Edit -> Preference Center
  • Edit the Cookie -> Fill the Source URL
Add Source URL to relevant Third-Party Cookies - Mandatly Inc.

OR

  • Go to Dictionary -> Edit the Cookie -> Fill the Source URL
Add Source URL to relevant Third-Party Cookies - Mandatly Inc.

For this you must recognize the third-party script placing this cookie.

For example, the third-party script placing the cookies of google analytics is as follows:

<script type=”text/javascript” async=”” src=”https://www.google-analytics.com/analytics.js”></script>

Just copy and paste the “google-analytics.com” in the Source Script Domain to block all the cookies placed by the above-mentioned script.

Additional resources: