Install the TermsFeed Privacy Consent cookie banner on HubSpot CMS in 4 steps, so one cookie banner decides what HubSpot and your other tools do. Setup takes about 20 minutes and needs a HubSpot user with permission to edit website settings. The steps cover website pages, landing pages, and blog posts that HubSpot hosts.

HubSpot adds its tracking code to every page it hosts, and pop-up forms and the chat widget load with that tracking code. The answer a visitor gives therefore has to reach HubSpot, which step 3 sets up. A site hosted elsewhere that only loads the tracking code follows Add HubSpot to TermsFeed Privacy Consent instead. Start by creating the consent banner with Create Your First TermsFeed Privacy Consent Banner.

Set disableHubSpotCookieBanner to true, as the first line of the code in step 2. The HubSpot cookie banner API asks for this flag near the top of the head, before the HubSpot consent banner loads, which is why Site footer HTML is too late.

Keep the HubSpot cookie policy of each domain set to wait for consent, and let Privacy Consent supply the answer. HubSpot keeps these policies under Settings > Privacy & Consent > Cookies.

Site header HTML prints into the <head> of every page on a domain. Click the settings icon in HubSpot, open Content > Pages, choose the domain or the default settings for all domains, and select the Templates tab.

Paste this code into Site header HTML, with the token from the Install page of your consent banner in place of YOUR_TOKEN, and save.

<script>
  window.disableHubSpotCookieBanner = true;
</script>

<!-- Privacy Consent by TermsFeed (https://www.termsfeed.com) -->
<script type="text/javascript" src="https://cdn.termsfeedtag.com/plugins/pc/v1/YOUR_TOKEN/plugin.js" async></script>
<!-- End Privacy Consent by TermsFeed (https://www.termsfeed.com) -->

Google tags added from their templates in the TermsFeed app need no Consent Mode code here. Your own Google Consent Mode v2 block goes between the flag and the snippet. Copy it from Set Up Google Consent Mode v2.

Step 3: Add the HubSpot tracking code as a Marketing vendor

Create a custom vendor whose vendor tags pass the answer to HubSpot with setHubSpotConsent. Skip the HubSpot template on hosted pages: it loads the tracking code a second time, on top of the copy HubSpot inserts. Open Vendors in the TermsFeed app, click "Add a vendor", choose the "Custom vendor" card, and fill in the form.

Field Value
"Vendor name" HubSpot
"Link to their Privacy Policy" https://legal.hubspot.com/privacy-policy
"What are they used for?" Marketing
"Purpose" "Measure your interest in our products and services and to personalize marketing interactions"

On the "JavaScript tags" tab, switch on "If allowed" and paste this vendor tag into its code field.

<script>
  var _hsp = window._hsp = window._hsp || [];
  _hsp.push(['setHubSpotConsent', {
    analytics: true,
    advertisement: true,
    functionality: true
  }]);
</script>

Next, switch on "If declined", paste this vendor tag into its code field, and click "Add vendor".

<script>
  var _hsp = window._hsp = window._hsp || [];
  _hsp.push(['setHubSpotConsent', {
    analytics: false,
    advertisement: false,
    functionality: false
  }]);
</script>

HubSpot does not save this value in its own consent cookies, so it needs the call on every page. Privacy Consent gives it that: a visitor with a saved answer gets the matching vendor tag on each page load. A withdrawal reaches HubSpot at the next page load, because on-decline tags wait for it after the vendor ran. Read how the 2 slots behave in Vendor Tag Trigger Actions.

HubSpot pop-up forms and the chat widget load with the tracking code, so they follow the consent HubSpot holds. Form modules placed in a page body render with the page whatever the visitor answers.

Step 4: Move other HubSpot integrations into vendors

HubSpot prints the scripts in these places before any consent, so they run whatever the visitor answers while they stay there. Check each place and move what you find into its own vendor.

  • The Integrations tab of the page settings. A Google Analytics or Google Tag Manager ID entered there prints its own tag.
  • Site header HTML and Site footer HTML. Any tracking snippet beside the code from step 2 belongs in a vendor.
  • The head of single pages. The "Additional code snippets" field under "Advanced" in the page editor holds code for one page.
  • Template modules and custom HTML modules. A module that embeds a pixel or a chat widget prints it on every page that uses the module.

Delete each script from HubSpot only after its vendor exists, so no page runs it twice. Copy the settings for the most common one from Add Google Analytics 4.

Edit the global footer in the HubSpot design manager or the page editor. Open the source view of a rich text module, and add this element beside your Privacy Policy link. Privacy Consent opens the Preferences Center for it, including when HubSpot renders it after the page loads.

<a href="#" id="open_privacy_preferences_element">Privacy Preferences</a>

Once Privacy Consent has started, it keeps an href="#" link from jumping to the top of the page. Compare this link with the floating button in Let Visitors Reopen Preferences.

A HubSpot account often serves the website on www.example.com, landing pages on info.example.com, and the blog on blog.example.com. A single entry for example.com under "What is your website domain?" on the Settings page covers all 3. List any other domain under "Additional domains".

HubSpot previews use a system domain ending in hs-sites.com, which carries the same Site header HTML, and the consent banner loads there without an entry. Each hostname keeps its own answer in the browser, so info.example.com asks a visitor who already answered on www.example.com. Add other domains with Run One TermsFeed Privacy Consent Banner Across Several Domains.

Publish a page and test the live address in a private window, because the page editor preview does not run every script a live page runs. A new consent banner starts on the Strict consent logic and asks every visitor. Standard in Settings leaves a visitor in a US state without one, so choose a test location from Cookie Banner by Visitor Location.

  1. Open Chrome DevTools, select the Network tab, type termsfeedtag in the filter box, and reload. 7 requests appear with status 200, ending with settings.json twice.
  2. Confirm that only the Privacy Consent banner shows, with no HubSpot consent banner beside it.
  3. Select the Application tab, open Cookies, and select your domain. The HubSpot cookies __hstc, hubspotutk, and __hssc are absent.
  4. Click I Agree and reload. The Application tab now lists __hstc and hubspotutk.
  5. Close every private window, open a new one, click I Decline, and reload. The Application tab lists neither cookie.

Filter the Network tab for events.push while you click, and each answer shows a request with status 201. A request to js.hs-scripts.com appears before any answer on a hosted page, because HubSpot inserts the tracking code itself. Finish with the remaining checks in Check That Your TermsFeed Privacy Consent Installation Works.

Most HubSpot problems come from HubSpot tracking that runs outside Privacy Consent.

  • The flag sits in Site footer HTML. disableHubSpotCookieBanner then runs too late, and 2 consent banners appear. Keep it in Site header HTML.
  • The HubSpot cookie policy allows tracking before consent. HubSpot sets its cookies on the first page view. Set the policy of each domain to wait for consent.
  • The vendor loads the tracking code. HubSpot already inserts it on hosted pages, so a second copy loads it twice. Keep only the setHubSpotConsent calls in the vendor tags.
  • Site header HTML is set for one domain only. Code set for a domain replaces the code set for all domains, so check each domain.
  • A Google Analytics ID stays in the Integrations tab. Google Analytics then runs before any answer. Clear the field once its vendor exists.

HubSpot shows its own consent banner beside Privacy Consent when the flag is missing. Tell the 2 apart and turn the extra one off with 2 Consent Banners Appear on a Site.