Difficulty Level: Advanced. This post assumes a strong understanding of HubSpot tools and technical knowledge. Insutructions are given as guidelines and may require additional customisation.
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:
Written by: Stephanie O'Gay Garcia Last Updated: February 6, 2023I'd appreciate if you could take a moment to let me know how I can improve this article.
Hi! 👋 I'm a freelance HubSpot Website Developer based in Toronto (Canada). Give me a shout if you have questions about this post or there's anything I can help you with.
HubSpot is a full suite of Marketing, Sales and Services tools. Learn more here.
Note: as a HubSpot affiliate I will earn commission if you decide HubSpot's the right software for you! :)