Skip to Content

Get HubSpot cookie (hubspotutk) using JavaScript

⚠️ Note that this post hasn't been updated for at least a year and the information may be outdated, proceed with caution! (Last updated: February 6, 2023)

To check whether a user has opted in or out of tracking cookies on HubSpot, you can use the use JavaScript's document.cookie method with RegEx to check the __hs_opt_out key:

 

It will return "no" if they have not opted out (are cookied) and "yes" if they have opted out (are not cookied).

If the user has not opted out of HubSpot cookies, you can also retrieve the HubSpot tracking cookie (hutk) using a similar document.cookie method with RegEx:

←  Previous Article

Optimise your HubSpot website speed

Next Article  →

Give a HubSpot custom module a unique ID

Contact

Get help from a HubSpot CMS Expert

  • Custom HubSpot themes and reusable and easy-to-use HubSpot templates and modules
  • Technical support and guidance on the HubSpot CMS