Articles on: Integrations

Hubspot integration - Consentmo

HubSpot Integration with Consentmo


This integration connects Consentmo consent choices with HubSpot so that HubSpot can adjust its tracking behavior according to the visitor's selected cookie preferences.


The bridge uses HubSpot's own consent and tracking APIs and maps Consentmo's consent categories to the corresponding HubSpot categories.


Important: Consentmo should be the only cookie banner shown to visitors when using this integration. The script disables HubSpot's own cookie banner to avoid displaying two separate consent interfaces.


How the Integration Works


The integration listens for consent changes from Consentmo and sends the corresponding consent state to HubSpot.


The category mapping is:


Consentmo category

HubSpot category

Analytics / Statistics

analytics

Marketing

advertisement

Functionality / Preferences

functionality


HubSpot's setHubSpotConsent method is then used to update these categories.


Strict Analytics Tracking Behavior


The integration also applies an additional tracking rule for HubSpot analytics.


If the visitor has not granted Analytics consent, the script calls:


window._hsq.push(['doNotTrack']);


This tells HubSpot not to send analytics tracking information.


When Analytics consent is granted, the integration calls:


window._hsq.push(['doNotTrack', { track: true }]);
window._hsq.push(['trackPageView']);


This re-enables HubSpot tracking and records the page view.


The integration therefore uses a stricter analytics behavior: HubSpot analytics tracking stays disabled until Analytics consent is available.


Default Consent State


Before the visitor makes a choice, the integration applies a safe default:


  • Analytics: Denied
  • Marketing / Advertisement: Denied
  • Functionality: Denied


This prevents HubSpot from being treated as consented before Consentmo has received the visitor's selection.


Consent Updates


The bridge listens for Consentmo's consentmoSignal event.


Whenever the visitor accepts, rejects, or changes their preferences, the new Consentmo state is sent to HubSpot automatically.


document.addEventListener('consentmoSignal', function (event) {
var preferences = event.detail && event.detail.preferences;
if (preferences) applyHubSpotConsent(preferences);
});


This means HubSpot's consent state stays synchronized with the visitor's latest Consentmo choice.


Applying the Integration


Add the following script to your Shopify theme where HubSpot and Consentmo are available.


A common placement is inside theme.liquid, before the closing </head> tag.


<script>
/* Consentmo is the only banner */
window.disableHubSpotCookieBanner = true;

window._hsp = window._hsp || [];
window._hsq = window._hsq || [];

function applyHubSpotConsent(preferences) {
var analytics = !!preferences.analytics;
var marketing = !!preferences.marketing;
var functionality = !!preferences.functionality;

/* Tell HubSpot the category choices */
window._hsp.push([
'setHubSpotConsent',
{
analytics: analytics,
advertisement: marketing,
functionality: functionality
}
]);

/*
Strict behaviour: no HubSpot beacon/data collection until
analytics consent exists.
*/
if (analytics) {
window._hsq.push(['doNotTrack', { track: true }]);
window._hsq.push(['trackPageView']);
} else {
window._hsq.push(['doNotTrack']);
}
}

/* Safe default for no choice yet */
applyHubSpotConsent({
analytics: false,
marketing: false,
functionality: false
});

/* Update when Consentmo obtains or changes consent */
document.addEventListener('consentmoSignal', function (event) {
var preferences = event.detail && event.detail.preferences;
if (preferences) applyHubSpotConsent(preferences);
});
</script>


What the Script Does


The integration performs the following actions:


  • Disables HubSpot's own cookie banner
  • Creates the HubSpot consent and tracking queues if they are not already available
  • Maps Consentmo consent categories to HubSpot consent categories
  • Sends the visitor's consent state to HubSpot
  • Keeps HubSpot analytics tracking disabled until Analytics consent is granted
  • Re-enables tracking when Analytics consent is granted
  • Updates HubSpot whenever the visitor changes their Consentmo preferences


Important Considerations


Consentmo should be the only banner


The script includes:


window.disableHubSpotCookieBanner = true;


This is intended to prevent HubSpot's own consent banner from appearing alongside Consentmo.


Using two consent banners can create conflicting consent states and a confusing experience for visitors.



In this implementation, Analytics consent controls whether HubSpot analytics tracking is enabled.


Marketing consent is separately mapped to HubSpot's advertisement category, while Functionality consent is mapped to functionality.


HubSpot may still use necessary cookies


Even when a visitor declines tracking, HubSpot may still use cookies it classifies as necessary.


HubSpot documents the cookies it uses and explains which ones are considered necessary or related to tracking.


Forms are separate from passive tracking


Blocking HubSpot analytics tracking does not necessarily mean that HubSpot forms stop working or that form submissions are prevented.


HubSpot forms and analytics tracking are separate parts of the platform, so form submissions may still function while optional tracking remains disabled.


How to Test the Integration


We recommend testing the integration in a private or incognito browser session.



Confirm that:


  • Consentmo is the only cookie banner displayed
  • HubSpot Analytics consent is false
  • HubSpot analytics tracking is disabled


After accepting Analytics


Confirm that:


  • HubSpot receives analytics: true
  • doNotTrack is removed
  • A page view can be sent


After rejecting Analytics


Confirm that:


  • HubSpot receives analytics: false
  • doNotTrack is enabled
  • Analytics tracking requests stop


You can also review HubSpot cookies from:


Browser DevTools → Application → Storage → Cookies


Testing in a fresh incognito session is recommended so existing cookies do not affect the result.


HubSpot Documentation


This integration is based on HubSpot's own consent and tracking mechanisms.


Useful HubSpot references include:


  • HubSpot Cookie Banner API

Covers category-level consent and the setHubSpotConsent method.
https://developers.hubspot.com/docs/reference/api/analytics-and-events/cookie-banner/cookie-banner-api


  • HubSpot cookie reference

Explains the cookies HubSpot may set and the __hs_do_not_track mechanism.
https://knowledge.hubspot.com/privacy-and-consent/what-cookies-does-hubspot-set-in-a-visitor-s-browser


  • HubSpot consent banner documentation

Explains how HubSpot handles visitor consent and cookie banner behavior.
https://knowledge.hubspot.com/privacy-and-consent/set-up-a-consent-banner-with-the-new-editor


Need help?


If you need assistance applying or testing the HubSpot integration, contact our support team through the in-app live chat or at support@consentmo.com.

Updated on: 08/10/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!