Home / Guides / Integrating HubSpot Consent API with CookieYes: A Practical Compliance Guide

Website Compliance

Integrating HubSpot Consent API with CookieYes: A Practical Compliance Guide

A practical guide for website owners on integrating HubSpot Consent API with CookieYes to ensure GDPR compliance. Covers step-by-step implementation, common mistakes, validation with GDPRChecker scanner, and a checklist to close the Consent Mode gap.

Author

GDPRChecker Editorial Team

Reviewed by

Privacy & Compliance Research Team

Last updated

July 2026

Reading time

10 min read

Educational guidance for compliance readiness — not legal advice. Requirements vary by jurisdiction and your specific processing activities.

Introduction

*Updated for 2026 compliance practices.*

Integrating HubSpot Consent API with CookieYes is a practical compliance topic for website owners validating consent, tags, and disclosures. If you use HubSpot for marketing automation and CookieYes as your consent management platform (CMP), connecting them ensures that user consent choices are respected across your HubSpot tracking scripts, forms, and cookies. This guide provides technical implementation steps, not legal advice. We'll cover what this integration means, requirements, a step-by-step implementation, common mistakes, and how to validate your setup using GDPRChecker's scanner. By the end, you'll have a clear path to close the Consent Mode gap and strengthen your site's GDPR posture.

Requirements and Compliance Expectations

Before implementing, understand the compliance expectations. The GDPR requires that you obtain explicit, informed consent before processing personal data via cookies or trackers, unless they are strictly necessary. HubSpot's tracking cookies (like `__hstc`, `hubspotutk`) are typically used for analytics and marketing, so they fall under non-essential categories. Therefore, they must be blocked until the user gives consent.

Key requirements: - **Consent categories**: Map HubSpot cookies to the correct consent categories in CookieYes (usually "Analytics" and "Marketing"). - **Prior blocking**: Ensure HubSpot scripts are not loaded or do not set cookies before consent. This can be done by adjusting the script loading logic or using CookieYes's blocking features. - **Consent propagation**: When consent is given or withdrawn, HubSpot must be notified immediately. The HubSpot Consent API provides methods like `doNotTrack` and `revokeCookieConsent` to manage this. - **Documentation**: Your privacy policy should disclose the use of HubSpot and how consent is managed. Link to your cookie policy from the banner.

Note that this guide provides technical implementation guidance, not legal advice. Always consult with a legal professional to ensure your specific setup meets regulatory requirements. The European Data Protection Board (EDPB) provides authoritative guidance on consent (see EDPB Guidelines).

How to Implement Step by Step

Here's a step-by-step implementation of integrating HubSpot Consent API with CookieYes. This assumes you have CookieYes installed and HubSpot tracking code on your site.

Step 1: Categorize HubSpot Cookies in CookieYes

Log into your CookieYes dashboard and go to the "Cookie List" or "Script Manager". Add HubSpot's cookies to the appropriate categories: - `__hstc`, `hubspotutk`, `__hssc`, `__hssrc`, `__hs_opt_out`, `__hs_do_not_track` → typically "Analytics" - `__hs_cookie_cat_pref` → "Functional" (if used for preference storage) - Any cookies set by HubSpot forms or chat → "Marketing"

Also, add the HubSpot script URL (e.g., `//js.hs-scripts.com/XXXXXX.js`) to the "Scripts" section and assign it to the "Analytics" category. This tells CookieYes to block the script until consent for that category is given.

Step 2: Modify HubSpot Tracking Code for Consent Awareness

By default, the HubSpot tracking code creates the `_hsq` global array. You can push commands to it to control tracking behavior. To make it consent-aware, you'll need to wrap the initialization or use the Consent API.

A common pattern is to not load the HubSpot script at all until consent is given. However, if you need to load it for essential functionality (like forms), you can use the `doNotTrack` method.

Example: Instead of loading the script immediately, you can load it dynamically after consent. But a simpler method is to let the script load but immediately tell HubSpot to not track until consent is given.

Add this code before the HubSpot script: ```javascript var _hsq = window._hsq = window._hsq || []; _hsq.push(['doNotTrack']); // Enable do-not-track by default ```

This tells HubSpot to not set tracking cookies. Then, when consent is granted, you can call `_hsq.push(['doNotTrack', false])` to disable do-not-track.

Step 3: Set Up CookieYes Callback for Consent Changes

CookieYes provides JavaScript callbacks that fire when consent is updated. You'll use these to communicate with HubSpot.

In your CookieYes script configuration (or in a custom script), add a callback function. For example: ```javascript window.addEventListener('cookieyes_consent_update', function(eventData) { var consentData = eventData.detail; // Check if analytics consent is given if (consentData.accepted.includes('analytics')) { _hsq.push(['doNotTrack', false]); // Optionally, reload HubSpot script if it was blocked } else { _hsq.push(['doNotTrack']); // Optionally, revoke existing cookies _hsq.push(['revokeCookieConsent']); } }); ```

This event listener reacts to consent changes. Adjust the category string ('analytics') to match what you've set in CookieYes.

Step 4: Handle Initial Page Load

On the first page load, before consent is given, HubSpot should be in do-not-track mode. If you've blocked the script entirely via CookieYes, you'll need to load it after consent. To do that, you can use the same callback to inject the script dynamically.

Example: ```javascript function loadHubSpotScript() { var script = document.createElement('script'); script.src = '//js.hs-scripts.com/XXXXXX.js'; script.id = 'hs-script-loader'; document.head.appendChild(script); }

window.addEventListener('cookieyes_consent_update', function(eventData) { if (eventData.detail.accepted.includes('analytics')) { if (!document.getElementById('hs-script-loader')) { loadHubSpotScript(); } } }); ```

This ensures HubSpot only loads after consent.

Step 5: Test the Integration

After implementation, thoroughly test: - Clear your browser cookies and cache. - Visit your site; the CookieYes banner should appear. - Before accepting, check that no HubSpot cookies are set (use browser developer tools > Application > Cookies). - Accept only necessary cookies; verify HubSpot cookies are still absent. - Accept analytics cookies; verify HubSpot cookies appear and tracking works. - Revisit and change consent; verify HubSpot cookies are removed or tracking stops.

Use GDPRChecker's scanner to automate this validation (see section below).

Common Mistakes and How to Avoid Them

Even with careful implementation, mistakes happen. Here are the most common ones and how to avoid them.

1. HubSpot Script Fires Before Consent

Mistake: The HubSpot tracking code is placed in the `<head>` without any blocking mechanism, so it loads and sets cookies immediately. Solution: Use CookieYes's script blocker to categorize the script, or implement the dynamic loading described above. Always test with a fresh browser session.

2. Incorrect Consent Category Mapping

Mistake: Mapping HubSpot cookies to the wrong category (e.g., "Necessary") so they are always allowed. Solution: Review the purpose of each cookie. HubSpot's own documentation states that its tracking cookies are for analytics and marketing. They should be under "Analytics" or "Marketing" and require consent.

3. Not Handling Consent Withdrawal

Mistake: When a user withdraws consent, HubSpot cookies are not deleted, and tracking continues. Solution: Use the `revokeCookieConsent` method and ensure your callback handles the withdrawal case. Also, consider manually deleting HubSpot cookies via JavaScript if needed.

4. Ignoring HubSpot Forms and Chat

Mistake: Focusing only on tracking cookies but forgetting that HubSpot forms and live chat also set cookies and process personal data. Solution: Ensure those scripts are also conditionally loaded based on consent. You may need to categorize them under "Marketing" or "Functional" as appropriate.

5. Not Testing with a Scanner

Mistake: Relying on manual testing alone, which can miss edge cases like pre-consent network requests. Solution: Use an automated scanner like GDPRChecker to verify that no HubSpot requests fire before consent. This catches issues you might overlook.

How to Validate with GDPRChecker

GDPRChecker scans help verify pre-consent network requests, banner behavior, and disclosure gaps after changes. After implementing the integration, run a scan to ensure compliance.

Here's how to use GDPRChecker for validation: 1. **Run a pre-consent scan**: Use the scanner to crawl your site as a first-time visitor. It will detect any cookies or network requests that occur before consent. Check the report for HubSpot-related requests (e.g., to `track.hubspot.com` or `js.hs-scripts.com`). If any appear, your blocking isn't working. 2. **Test consent flows**: Use the scanner's interaction mode to simulate accepting and rejecting different categories. Verify that HubSpot requests only appear after the appropriate consent is given. 3. **Check banner behavior**: Ensure the CookieYes banner appears correctly and that the "Reject" button works as expected. The scanner can flag if rejecting still results in tracking. 4. **Review disclosure gaps**: The scanner may check if your privacy policy mentions HubSpot and if the cookie list is accurate. Update your policy if needed.

Regular scans after any site changes (new plugins, script updates) help maintain compliance. For more on consent validation, see our guide on Google Consent Mode v2 Checker.

Implementation Checklist

Use this checklist to ensure you've covered all steps:

  1. [ ] Identified all HubSpot cookies and scripts used on your site.
  2. [ ] Categorized each cookie/script correctly in CookieYes (Analytics, Marketing, etc.).
  3. [ ] Configured CookieYes to block HubSpot scripts by default.
  4. [ ] Added the `doNotTrack` command to HubSpot initialization.
  5. [ ] Set up a CookieYes consent update callback to enable/disable HubSpot tracking.
  6. [ ] Implemented dynamic script loading if blocking the script entirely.
  7. [ ] Handled consent withdrawal with `revokeCookieConsent`.
  8. [ ] Tested all consent scenarios manually (accept all, reject all, partial consent).
  9. [ ] Verified that HubSpot forms/chat respect consent choices.
  10. [ ] Updated privacy policy to reflect HubSpot data processing and consent management.
  11. [ ] Ran a GDPRChecker scan to validate pre-consent requests and banner behavior.
  12. [ ] Scheduled regular scans to catch regressions.

FAQ

What is integrating HubSpot Consent API with CookieYes? Integrating HubSpot Consent API with CookieYes means connecting CookieYes's consent management with HubSpot's tracking scripts so that HubSpot only processes data when the user has given appropriate consent. It ensures compliance by blocking or limiting HubSpot's cookies and network requests until consent is obtained.

Do I need integrating HubSpot Consent API with CookieYes for GDPR? If you use HubSpot for tracking, forms, or chat, and you serve EU visitors, you likely need this integration. The GDPR requires prior consent for non-essential cookies. Without integration, HubSpot may set cookies before consent, creating a compliance gap. Technical implementation is not a legal requirement but a practical necessity.

How do I implement integrating HubSpot Consent API with CookieYes? Implement by categorizing HubSpot scripts in CookieYes, using HubSpot's `doNotTrack` method by default, and setting up a CookieYes callback to enable tracking when consent is given. You can also dynamically load the HubSpot script after consent. Always test thoroughly with manual checks and a scanner.

How can I verify integrating HubSpot Consent API with CookieYes with a scanner? Use GDPRChecker's scanner to crawl your site as a new visitor. It will detect any pre-consent network requests to HubSpot domains. You can also simulate consent interactions to ensure tracking only starts after consent. The scanner provides a report highlighting any issues.

What are common integrating HubSpot Consent API with CookieYes mistakes? Common mistakes include: loading HubSpot before consent, miscategorizing cookies as necessary, not handling consent withdrawal, forgetting about HubSpot forms/chat, and failing to test with a scanner. These can lead to unauthorized tracking and potential GDPR violations.

Next step

Run a GDPRChecker scan to validate consent behavior, trackers, and disclosures after you implement the checklist above.

<!-- schema:faq ready -->

GDPRChecker guides are educational resources and do not constitute legal advice. Use them to understand technical and operational privacy requirements, and consult qualified counsel for legal interpretation.

Check Your Website in Under 60 Seconds

  • No signup required
  • GDPR-focused checks
  • Cookie banner detection
  • Privacy policy verification
Integrating HubSpot Consent API with CookieYes | GDPRChecker Guide | GDPRChecker