Cluster 15 · CRM & Support SaaS · _hsq + Deferred Intercom

HubSpot & Intercom Pre-Consent Script Gating Guide (_hsq doNotTrack & Deferred Boot)

Prevent HubSpot (`hubspotutk`, `__hstc`) and Intercom (`intercom-id-*`) from dropping marketing or tracking cookies before user consent using `_hsq` suppression and conditional widget loading.

100% Browser-Side · Zero User-Data Upload · Strict CSP

Compliance & Pre-Consent Control Specification

Control / Signal Compliant Baseline Engineering & Privacy Rationale
HubSpot Cookies __hstc, hubspotutk, __hssc Marketing & attribution cookies dropped immediately unless HubSpot Cookie Banner API / `doNotTrack` blocks them
HubSpot Suppression _hsq.push(['doNotTrack']) Tell HubSpot tracking code not to drop cookies before marketing/analytics consent
Intercom Storage intercom-id-*, intercom-session-* Load Intercom script only on user click ('Chat with us') or after functional/support consent
Zero Pre-Consent Leak Conditional <script> injection Defer loading `js.hs-scripts.com` and `widget.intercom.io` until explicit consent or launcher click

Deferred HubSpot & Intercom Loader (Zero Pre-Consent Cookies)

crm-chat-consent-gate.ts
export function loadHubSpotAfterConsent(portalId: string) {
  if (document.getElementById("hs-script-loader")) return;
  const s = document.createElement("script");
  s.id = "hs-script-loader";
  s.async = true;
  s.defer = true;
  s.src = `https://js.hs-scripts.com/${encodeURIComponent(portalId)}.js`;
  document.head.appendChild(s);
}

export function loadIntercomOnConsentOrClick(appId: string) {
  if (window.Intercom) return;
  const s = document.createElement("script");
  s.async = true;
  s.src = `https://widget.intercom.io/widget/${encodeURIComponent(appId)}`;
  s.onload = () => window.Intercom?.("boot", { app_id: appId });
  document.head.appendChild(s);
}

HubSpot _hsq Revoke / Consent Banner API Hook

hubspot-cmp-bridge.js
window._hsq = window._hsq || [];
// Suppress HubSpot tracking pre-consent:
window._hsq.push(["doNotTrack"]);

// When user grants analytics/marketing consent:
export function enableHubSpotTracking() {
  window._hsq.push(["doNotTrack", { track: true }]);
}

Implementation Steps & Key Insights

  1. Inspect `document.cookie` on initial load for `__hstc`, `hubspotutk`, `__hssrc`, and `intercom-id-*`.
  2. Remove static `<script src='https://js.hs-scripts.com/...'>` embeds or gate them via GTM Additional Consent Checks / JS consent hooks.
  3. Render a lightweight zero-cookie 'Open Support Chat' launcher button that loads `widget.intercom.io` only when clicked or after support consent.
  4. Disable HubSpot marketing pixels on checkout routes too (PCI DSS v4.0.1 Req. 6.4.3 also flags unapproved marketing scripts on payment pages).
  • HubSpot's `js.hs-scripts.com` is one of the top pre-consent cookies leaked on B2B SaaS marketing sites (and checkout routes!).
  • A two-click or deferred Intercom launcher improves Lighthouse performance/LCP while keeping pre-consent third-party cookies at zero.
  • Run both `consent.runglab.dev` (GDPR pre-consent) and `pci.runglab.dev` (checkout script hygiene) to catch hidden HubSpot tags.

Common Pre-Consent Pitfalls

  • Placing HubSpot chat/analytics globally in a footer layout without gating on consent.
  • Calling `Intercom('boot')` on public marketing pages for anonymous visitors without prior notice/consent.
  • Forgetting to check EU HubSpot CDN variant (`js-eu1.hs-scripts.com`).
Verify Live: Audit your production site on consent.runglab.dev or grab the $39 ConsentCheck Compliance Pack. Not legal advice.

More GDPR, Consent Mode v2 & GPC Implementation Guides

← Back to GDPR & Consent Mode v2 Hub · ConsentCheck Live Audit → · $39 Compliance Pack → · Cluster 4: Security Headers → · Cluster 11: PCI & SRI →

Frequently Asked Questions

Does Intercom require cookie consent on a marketing site?

While an active chat explicitly initiated by a user can be strictly necessary to deliver support, loading `widget.intercom.io` and setting `intercom-id-*` tracking cookies automatically for every passive visitor typically triggers ePrivacy consent rules.

How do I stop HubSpot from dropping `hubspotutk` before consent?

Either inject `hs-scripts.com` dynamically only after CMP consent, or push `['doNotTrack']` onto `window._hsq` before HubSpot initializes.

Where can I check if HubSpot or Intercom drops cookies before consent on my domain?

Run a free live audit at https://consent.runglab.dev/?ref=tool-consent-cluster.