CMS Development

ICaceres
Member

blocking LinkedIn cookies using OneTrust cookie consent banner script

SOLVE

how we can block LinkedIn cookies using the OneTrust cookie consent banner script?

we now, have to use:
<script type="text/plain" class="optanon-category-C0002">

//what is the code to block the LinkedIn cookie?

</script>

because : 

  _hsq.push(['doNotTrack']);  or  _hsp.push(['doNotTrack']); doesn't work
Best Regards.

 

0 Upvotes
1 Accepted solution
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

blocking LinkedIn cookies using OneTrust cookie consent banner script

SOLVE

Hello @ICaceres 

To block LinkedIn cookies using the OneTrust cookie consent banner script, you can use the following code within the <script type="text/plain" class="optanon-category-C0002"> tag

<script type="text/plain" class="optanon-category-C0002">
  // Block LinkedIn cookies
  window.onload = function() {
    var liCookies = document.cookie.match(/(?:^|;)\s*_lipt=([^;]+)/);
    if (liCookies) {
      var cookieString = "_lipt=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
      document.cookie = cookieString;
    }
  }
</script>

 

This code will check if the _lipt LinkedIn cookie exists and if it does, it will set it to expire immediately, effectively blocking it. The code is triggered when the page is fully loaded using the window.onload function.

Note that this solution may not be sufficient to fully block all LinkedIn cookies, as there may be other cookies that LinkedIn uses. It's recommended to review LinkedIn's cookie policy and adjust the code as needed to block all relevant cookies.



Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

1 Reply 1
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

blocking LinkedIn cookies using OneTrust cookie consent banner script

SOLVE

Hello @ICaceres 

To block LinkedIn cookies using the OneTrust cookie consent banner script, you can use the following code within the <script type="text/plain" class="optanon-category-C0002"> tag

<script type="text/plain" class="optanon-category-C0002">
  // Block LinkedIn cookies
  window.onload = function() {
    var liCookies = document.cookie.match(/(?:^|;)\s*_lipt=([^;]+)/);
    if (liCookies) {
      var cookieString = "_lipt=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
      document.cookie = cookieString;
    }
  }
</script>

 

This code will check if the _lipt LinkedIn cookie exists and if it does, it will set it to expire immediately, effectively blocking it. The code is triggered when the page is fully loaded using the window.onload function.

Note that this solution may not be sufficient to fully block all LinkedIn cookies, as there may be other cookies that LinkedIn uses. It's recommended to review LinkedIn's cookie policy and adjust the code as needed to block all relevant cookies.



Digital Marketing & Inbound Expert In Growth Hacking Technology