# How to access cookie ID

**URL:** <https://community.hubspot.com/t/how-to-access-cookie-id/132582>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [May 13, 2025, 7:36am UTC](https://community.hubspot.com/t/how-to-access-cookie-id/132582 "2025-05-13T07:36:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MTarnopolska](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@MTarnopolska](https://community.hubspot.com/u/MTarnopolska)\
**Post date:** [May 13, 2025, 7:36am UTC](https://community.hubspot.com/t/how-to-access-cookie-id/132582/1 "2025-05-13T07:36:25Z")

</div>

Hello everyone,

We are looking into some projects where we would need to access HubSpot cookie ID. We are not sure yet which solution we may use and it’s possible that we will just use our custom code.

Thank you in advance!

Kind regards,

Mila

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [May 13, 2025, 3:21pm UTC](https://community.hubspot.com/t/how-to-access-cookie-id/132582/2 "2025-05-13T15:21:06Z")

</div>

Hi @MTarnopolska, I hope that you are well!  
Great question, thanks for asking the HubSpot Community!  
For information around the topic, here are some resources that might be of interest:  
- [Cookies set in your visitor’s browser by HubSpot](https://knowledge.hubspot.com/privacy-and-consent/what-cookies-does-hubspot-set-in-a-visitor-s-browser)  
- [Track visitors in HubSpot](https://knowledge.hubspot.com/account/how-does-hubspot-track-visitors)  
- [Cookies set on HubSpot’s websites](https://knowledge.hubspot.com/privacy-and-consent/hubspot-cookie-security-and-privacy)  
- [Cookie consent banner API](https://developers.hubspot.com/docs/reference/api/analytics-and-events/cookie-banner/cookie-banner-api)  
Also, I have found this similar post that might help you, more precisely, the solution from @ModuleMaestro on this post “[HubSpot Cookie](https://community.hubspot.com/t5/CMS-Development/HubSpot-Cookie/m-p/840203)”.  
Let me know if that helped?  
Have a great day! 🌞  
Bérangère

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [May 19, 2025, 2:25pm UTC](https://community.hubspot.com/t/how-to-access-cookie-id/132582/3 "2025-05-19T14:25:48Z")

</div>

Hi @MTarnopolska

"Here is the way to get Hubspotutk

```lia-code-sample
function getHubSpotCookie() {
 const name = ""hubspotutk="";
 const decodedCookie = decodeURIComponent(document.cookie);
 const cookies = decodedCookie.split(';');
 for (let i = 0; i < cookies.length; i++) {
 let c = cookies[i].trim();
 if (c.indexOf(name) === 0) {
 return c.substring(name.length, c.length);
 }
 }
 return null;
}

const hubspotutk = getHubSpotCookie();
console.log(""HubSpot Cookie ID to send:"", hubspotutk);

```

Now you can use it as per your requirement."

I hope this will help you out. Please mark it as **Solution Accepted and upvote** to help another Community member.  
Thanks!
