# blocking LinkedIn cookies using OneTrust cookie consent banner script

**URL:** <https://community.hubspot.com/t/blocking-linkedin-cookies-using-onetrust-cookie-consent-banner-script/80178>\
**Category:** CMS Development\
**Tags:** integrations, content, how-to\
**Created:** [April 27, 2023, 2:03pm UTC](https://community.hubspot.com/t/blocking-linkedin-cookies-using-onetrust-cookie-consent-banner-script/80178 "2023-04-27T14:03:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ICaceres](https://avatars.discourse-cdn.com/v4/letter/i/a698b9/32.png) [@ICaceres](https://community.hubspot.com/u/ICaceres)\
**Post date:** [April 27, 2023, 2:03pm UTC](https://community.hubspot.com/t/blocking-linkedin-cookies-using-onetrust-cookie-consent-banner-script/80178/1 "2023-04-27T14:03:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [April 28, 2023, 7:08am UTC](https://community.hubspot.com/t/blocking-linkedin-cookies-using-onetrust-cookie-consent-banner-script/80178/2 "2023-04-28T07:08:01Z")

</div>

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

```lia-code-sample
<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.

---

<div class="post-metadata">

**Author:** ![StephaneLM](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@StephaneLM](https://community.hubspot.com/u/StephaneLM)\
**Post date:** [January 28, 2025, 3:34am UTC](https://community.hubspot.com/t/blocking-linkedin-cookies-using-onetrust-cookie-consent-banner-script/80178/3 "2025-01-28T03:34:20Z")

</div>

I know it’s been a few months, but you can look into other cookie banner solutions that are much simpler to implement. They’re called [consent management platforms](https://www.ketch.com/blog/posts/consent-management) (CMPs). You can start with [free CMP](https://www.ketch.com/ketch-free-cookie-banner) solutions first too. Hope this helps!
