GDPRChecker

Home / Knowledge Base / Google Analytics 4 Cookie Consent on HubSpot CMS: Setup, Blocking, and Testing

Website Compliance

Google Analytics 4 Cookie Consent on HubSpot CMS: Setup, Blocking, and Testing

A practical guide for website owners on implementing Google Analytics 4 cookie consent on HubSpot CMS. Covers step-by-step setup, blocking tracking before consent, common mistakes, and validation using GDPRChecker's scanner. Includes an implementation checklist and FAQ to help ensure GDPR compliance.

Run a free GDPR compliance scanPreview the findings before choosing a CMP.

Author

GDPRChecker Editorial Team

Reviewed by

Privacy & Compliance Research Team

Last updated

July 2026

Reading time

9 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.

Google Analytics 4 HubSpot CMS cookie consent is a practical compliance topic for website owners validating consent, tags, and disclosures. If you run a website on HubSpot CMS and use Google Analytics 4 (GA4) to understand visitor behavior, you need to manage cookie consent properly under regulations like the GDPR. This guide walks you through the technical steps to implement cookie consent for GA4 on HubSpot CMS, block tracking before consent, and verify everything works using GDPRChecker’s scanner. We’ll cover consent defaults, tag manager triggers, policy disclosures, Reject-flow testing, and post-change scans. Remember, this guide provides technical implementation guidance, not legal advice. Always consult a qualified privacy professional for your specific legal obligations.

Requirements and Compliance Expectations

Before diving into implementation, let’s clarify the compliance expectations. The GDPR requires that consent be freely given, specific, informed, and unambiguous. For GA4, this means:

  • Prior blocking: No GA4 cookies or tracking requests should be set or sent before the user gives consent.
  • Granular choice: Users should be able to accept or reject analytics cookies separately from other categories.
  • Easy withdrawal: It must be as easy to withdraw consent as it is to give it.
  • Documentation: You must keep records of consent.

Google’s own Consent Mode allows you to adjust GA4 behavior based on consent state. When consent is denied, GA4 can still send cookieless pings for aggregated modeling, but this must be configured correctly. The European Data Protection Board (EDPB) has emphasized that consent must be explicit, and pre-ticked boxes or implied consent are not valid.

For HubSpot CMS, you’ll need to ensure that any default HubSpot tracking (like the HubSpot analytics cookie) also respects consent. This guide focuses on GA4, but the principles apply broadly.

How to Implement Step by Step

Implementing Google Analytics 4 HubSpot CMS cookie consent involves several layers: the consent banner, the tag management system, and the GA4 configuration. Below is a step-by-step approach.

Step 1: Choose a Consent Management Platform (CMP)

HubSpot CMS offers a built-in consent banner, but it may not provide the granular control needed for GA4 Consent Mode. Many users opt for a third-party CMP that integrates with Google Tag Manager (GTM) or directly with the site. Look for a CMP that supports Google Consent Mode v2 and can push consent states to the data layer. If you don’t run Google Ads, you might still need a CMP for analytics consent; see our guide on do-i-need-a-cmp-if-i-do-not-run-google-ads for more context.

Step 2: Configure Google Consent Mode

Google Consent Mode allows you to set default consent states for different types of consent (e.g., analytics_storage, ad_storage). The default should be denied for all categories that require consent. Then, when the user grants consent, the CMP updates the consent state to granted. This is typically done via GTM or by adding a small script to your HubSpot pages.

Here’s a basic example of the default consent script you might add to the <head> of your HubSpot site:

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('consent', 'default', {
    'analytics_storage': 'denied',
    'ad_storage': 'denied',
    'ad_user_data': 'denied',
    'ad_personalization': 'denied',
    'wait_for_update': 500
  });
</script>

This ensures that until consent is updated, GA4 will not set analytics cookies. The wait_for_update parameter tells Google tags to wait for a consent update before firing. For more details, see Google’s Consent Mode documentation.

Step 3: Set Up GA4 in Google Tag Manager (or Directly)

If you use GTM, create a GA4 Configuration tag and set it to fire on all pages. However, you must add a trigger exception based on consent. With Consent Mode, the GA4 tag will respect the consent state automatically if you’ve set the default correctly. But to be safe, you can create a custom trigger that only fires when analytics_storage is granted.

If you’re adding GA4 directly to HubSpot CMS (e.g., via the site header HTML), you’ll need to wrap the GA4 script in a condition that checks consent. This is more error-prone, so using GTM is recommended.

Step 4: Integrate the CMP with HubSpot CMS

Most CMPs provide a JavaScript snippet that you add to your HubSpot site, usually in the site header or via GTM. The CMP will display the banner and, upon user choice, push consent events to the data layer. Ensure that the CMP fires early in the page load to set defaults before any tags fire.

HubSpot CMS allows you to add custom code in the “Site Header HTML” or “Footer HTML” settings. Place the CMP script in the header so it loads first.

Step 5: Test the Implementation

After setup, you must test thoroughly. Use browser developer tools to check network requests. Before consent, you should see no requests to google-analytics.com or googletagmanager.com that set cookies. After granting consent, those requests should appear. Also test the reject flow: when a user rejects cookies, GA4 should not set cookies, and if using Consent Mode, only cookieless pings should be sent.

GDPRChecker’s scanner can automate this testing. It verifies pre-consent network requests, banner behavior, and disclosure gaps after changes. Run a scan before and after implementation to confirm compliance.

Common Mistakes and How to Avoid Them

Even with careful setup, mistakes happen. Here are the most common pitfalls with Google Analytics 4 HubSpot CMS cookie consent and how to avoid them.

1. GA4 Fires Before Consent

This is the most critical error. If your GA4 tag fires on page load without waiting for consent, you’re collecting data without permission. To avoid this, always set default consent to denied and ensure your GA4 tag respects Consent Mode. Use GTM’s built-in consent settings or custom triggers.

2. Incorrect Consent Defaults

Setting defaults to granted or omitting the default consent script entirely means GA4 will assume consent until told otherwise. This violates GDPR. Always start with denied.

3. Not Testing the Reject Flow

Many implementations only test the accept flow. But if a user rejects cookies, GA4 should not set cookies. If you’re using Consent Mode, it should switch to cookieless pings. Test this by rejecting cookies in your banner and checking for GA4 cookies in browser storage.

4. Missing Policy Disclosures

Your cookie banner must link to a privacy policy that explains what GA4 does, what data it collects, and how users can withdraw consent. Without this, consent is not informed. Ensure your privacy policy is up to date and easily accessible.

5. Ignoring HubSpot’s Own Cookies

HubSpot CMS sets its own analytics cookies. If you’re using HubSpot’s built-in analytics, you must also obtain consent for those. The same principles apply: block them before consent and only fire after opt-in.

6. Not Updating After Changes

Whenever you update your GA4 configuration, add new tags, or change your CMP, you must re-verify consent flows. A scanner like GDPRChecker helps catch regressions quickly.

How to Validate with GDPRChecker

GDPRChecker scans help verify pre-consent network requests, banner behavior, and disclosure gaps after changes. Here’s how to use it for your Google Analytics 4 HubSpot CMS cookie consent setup.

  1. Run a baseline scan: Before making changes, scan your site to see current cookie behavior. Note any GA4 requests that fire without consent.
  2. Implement consent: Follow the steps above to add a CMP, set default consent, and configure GA4.
  3. Run a post-implementation scan: GDPRChecker will crawl your site and report on cookies, network requests, and banner presence. It will flag any tags that fire before consent.
  4. Check the banner: The scanner verifies that a consent banner appears, that it blocks tracking until interaction, and that it provides a reject option.
  5. Review the report: Look for gaps in disclosures, missing policy links, or tags that still fire prematurely.
  6. Re-scan after fixes: Iterate until the scan shows no pre-consent GA4 requests and proper consent handling.

For a deeper dive into Consent Mode validation, see our google-consent-mode-v2-checker guide.

Implementation Checklist

Use this checklist to ensure you’ve covered all bases for Google Analytics 4 HubSpot CMS cookie consent.

  1. Choose a CMP that supports Google Consent Mode v2.
  2. Add the CMP script to HubSpot CMS header, ensuring it loads before other tags.
  3. Set default consent states to denied for analytics_storage, ad_storage, etc.
  4. Configure GA4 tag in GTM to respect consent (or add conditional logic if direct).
  5. Verify that GA4 does not fire on page load before consent (check network tab).
  6. Test the accept flow: after clicking “Accept,” GA4 cookies should be set and requests sent.
  7. Test the reject flow: after clicking “Reject,” no GA4 cookies should be set; only cookieless pings if using Consent Mode.
  8. Ensure your cookie banner links to a privacy policy that explains GA4 data collection.
  9. Check that HubSpot’s own analytics cookies are also blocked before consent.
  10. Run a GDPRChecker scan to validate pre-consent behavior and banner compliance.
  11. Document your consent setup and keep records of consent logs if your CMP provides them.
  12. Re-scan after any changes to tags, CMP, or privacy policy.

FAQ

What is Google Analytics 4 HubSpot CMS cookie consent?

Google Analytics 4 HubSpot CMS cookie consent is the process of obtaining user permission before loading GA4 tracking scripts on a HubSpot CMS website. It involves displaying a consent banner, blocking cookies until opt-in, and configuring GA4 to respect user choices, typically using Google Consent Mode.

Do I need Google Analytics 4 HubSpot CMS cookie consent for GDPR?

Yes, if you use GA4 on a HubSpot CMS site and have visitors from the EU/EEA, you generally need cookie consent under GDPR. Analytics cookies are not strictly necessary, so they require prior consent. This applies even if you don’t run ads.

How do I implement Google Analytics 4 HubSpot CMS cookie consent?

Implement by adding a CMP to your HubSpot site, setting default consent to denied via Google Consent Mode, and configuring GA4 to fire only after consent is granted. Use GTM for easier management, and test thoroughly with browser tools and GDPRChecker scans.

How can I verify Google Analytics 4 HubSpot CMS cookie consent with a scanner?

Use GDPRChecker to scan your site. It checks for pre-consent network requests, banner behavior, and disclosure gaps. Run a scan before and after implementation to ensure no GA4 tags fire without consent and that the banner meets requirements.

What are common Google Analytics 4 HubSpot CMS cookie consent mistakes?

Common mistakes include GA4 firing before consent, incorrect default consent states (set to granted), not testing the reject flow, missing policy disclosures, ignoring HubSpot’s own cookies, and failing to re-verify after changes. Use a scanner to catch these issues.

Next Steps for Compliance

Implementing Google Analytics 4 HubSpot CMS cookie consent is a critical step toward GDPR compliance. By following this guide, you’ve learned how to set up consent defaults, block tracking before opt-in, and validate your setup with GDPRChecker. Remember, compliance is not a one-time task; you must regularly review your configuration, especially after platform updates or changes to your analytics setup.

For further reading, explore our related guides on google-analytics-gdpr-compliance, google-consent-mode-v2-guide, and cookie-banner-requirements. To close any remaining gaps, run a GDPRChecker scan today and ensure your HubSpot CMS site respects user consent for Google Analytics 4.

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

  • Sign in required
  • GDPR-focused checks
  • Cookie banner detection
  • Privacy policy verification