- Kennisbank
- Account & Opstelling
- Privacy en toestemming
- De toestemmingsmodus van Google begrijpen en implementeren
De toestemmingsmodus van Google begrijpen en implementeren
Laatst bijgewerkt: 3 september 2026
Beschikbaar met elk van de volgende abonnementen, behalve waar vermeld:
De Google Consent Mode is een raamwerk dat is ontworpen om de toestemmingsvoorkeuren van websitebezoekers te integreren met de advertentie- en analysetools van Google. Met de Consent Mode kan uw site het gedrag van deze tools aanpassen op basis van de toestemmingsstatus van websitebezoekers, met name wat betreft cookies en het verzamelen van gegevens. Zelfs wanneer bezoekers geen toestemming geven voor cookies, kunnen Google-services in een beperkte modus blijven werken en basisinteracties vastleggen zonder de privacyverwachtingen te schenden.
Let op: vanaf de door Google vastgestelde deadline in maart 2024 kunnen bedrijven die geen integratie met Google Consent Mode v2 hebben, te maken krijgen met meetverlies van bijgehouden gegevens van bezoekers uit de EER, de EU en het VK.
Voordat u aan de slag gaat
Vanwege de vereiste van uitdrukkelijke toestemming van Google werkt de Consent Mode alleen in de EER, de EU en het VK als er voor die bezoekers een HubSpot-banner voor toestemming voor opt-in-cookies (met of zonder categorieën) wordt weergegeven.
Om de Google Consent Mode in te schakelen, moet je aan de volgende criteria voldoen:
- Je moet een door HubSpot gehoste website hebben.
- Je moet geïntegreerd zijn met Google Tag Manager of Google Analytics.
- Gebruik de banner voor toestemming voor cookies van HubSpot.
Als u een website en toestemmingsbanner gebruikt die niet door HubSpot worden gehost, of als u een aangepaste Google Tag Manager of Google Analytics hebt, lees dan hoe u de Google Consent Mode handmatig kunt implementeren.
Schakel de Google Consent Mode in
Om de Google Consent Mode in te schakelen voor een door HubSpot gehoste website:
- Stel een HubSpot-banner voor toestemming voor cookies in . Selecteer tijdens het instellen van je banner in het vervolgkeuzemenu ‘Landen’ de landen van de EU, de EER en het VK.
- Integreer Google Analytics 4 (ondersteunt de geavanceerde toestemmingsmodus) met je meting-ID of Google Tag Manager (ondersteunt de standaard toestemmingsmodus) met je GTM-ID rechtstreeks in je HubSpot-account.
Let op: als je voor Google Analytics 4 de basisversie van de toestemmingsmodus ( ) wilt implementeren in plaats van de geavanceerde versie, kun je Google Analytics als tag toevoegen aan Google Tag Manager. Vervolgens wordt deze via de Google Tag Manager-integratie van HubSpot geladen met de basis- toestemmingsmodus.
Zodra deze stappen zijn voltooid, wordt Google Consent Mode v2 wereldwijd ondersteund op je door HubSpot gehoste content.
Google Consent Mode handmatig implementeren
Als je website niet in HubSpot wordt gehost, je geen integratie hebt met GTM of GA4 via een Measurement-ID of GTM-ID, of je een cookiebanner van een andere aanbieder dan HubSpot gebruikt, moet je Google Consent Mode handmatig implementeren.
Externe site
Als je de HubSpot-cookiebanner op een externe website gebruikt, werk dan samen met je ontwikkelaar om de Consent Mode handmatig te implementeren.
Aangepaste Google Tag Manager of Google Analytics
Als je niet via een Measurement ID of GTM ID binnen HubSpot bent geïntegreerd met GTM of GA4 en een codefragment gebruikt voor de integratie, moet je de Consent Mode handmatig implementeren. Werk samen met je ontwikkelaar om de Consent Mode handmatig te implementeren.
Externe cookiebanner
Als je een cookie-banner van een andere aanbieder dan HubSpot gebruikt op je door HubSpot gehoste site of op pagina's van je externe website, neem dan contact op met de aanbieder of ontwikkelaar van je externe cookie-banner voor advies.
Gerelateerde documentatie
- Home Analytics & Events Cookie bannerCookie consent banner APISuper admins and users with permission to edit website settings can customize visitor cookie tracking and consent banners to comply with EU cookie laws and the General Data Protection Regulation (GDPR).A cookie consent banner allows visitors to opt in or opt out of being tracked in your HubSpot account with cookies. This feature works for all HubSpot pages as well as any external pages with your HubSpot tracking code installed. Customize the cookie tracking settings and cookie consent banner.In this article, learn how to manage the cookies that are added to a visitor's browser through the cookie consent banner.Remove cookies_hsp.push(['revokeCookieConsent']);Remove the cookies created by the HubSpot tracking code that are included in the consent banner under GDPR, include the HubSpot cookies related to tracking the visitor. As a result of the cookies being removed, the visitor would see the cookie consent banner on their next page load, as they would appear as a new visitor.This function does not remove cookies placed by non-HubSpot banners. You can find the specific list of cookies that will be removed on HubSpot's Knowledge Base. If cookie blocking is turned on, this function will revoke consent so any third-party cookies will not be updated or dropped during future visits to the website. JavaScript/*Example code to remove the consent banner cookieswhen a visitor clicks an element with the 'removeCookies' id.*/var _hsp = window._hsp = window._hsp || [];document.getElementById("removeCookies").onclick = function() { _hsp.push(['revokeCookieConsent']);};Place do not track cookie_hsq.push(['doNotTrack']);Places the __hs_do_not_track cookie in the visitors browser, which will prevent the HubSpot tracking code from sending any information for the visitor.You can remove the cookie by calling the function again and including the {track: true} argument:_hsq.push(['doNotTrack', {track: true}]);Please note: this function prevents all information from being collected by the tracking code, including anonymized traffic and custom event data.JavaScript/*Example code to place the __hs_do_not_track cookie forthe visitor when they click an element with the 'doNotTrack' id.*/document.getElementById("doNotTrack").onclick = function() { _hsq.push(['doNotTrack']);};Get privacy consent status_hsp.push(['addPrivacyConsentListener', callbackFunction]);Get the privacy consent status of the current visitor. There are 3 categories of consent that can be used to provide more granular control to the user. These each have their own keys within the consent.categories object:consent.categories.analyticsconsent.categories.advertisementconsent.categories.functionalityThe callbackFunction will be called, depending on the state of the page:If the banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline:the callbackFunction will be called immediately if the banner code is already loaded.the callbackFunction will be called after the tracking code loads if the function is pushed to _hsp before the tracking code loads.If the banner is enabled, the callback function will be called when the visitor clicks on the accept or decline button. JavaScript// Log the analytics category consent status of the current visitor to the consolevar _hsp = window._hsp = window._hsp || [];// analytics_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.analytics); }]);// advertisement_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.advertisement); }]);// functionality_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.functionality); }]);// or it can all be done in one call_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(`analytics: ${consent.categories.analytics}`); console.log(`advertisement: ${consent.categories.advertisement}`); console.log(`functionality: ${consent.categories.functionality}`); }]);Cookies not by categoryPlease note: This is provided for backward compatibility with older scripts. For all new websites you should use the cookies by category method, giving more granular control over cookie activation._hsp.push(['addPrivacyConsentListener', callbackFunction]);Allows you to get the true or false privacy consent status of the current visitor.The callbackFunction will be called, depending on the state of the page:If the banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline:the callbackFunction will be called immediately if the banner code is already loaded.the callbackFunction will be called after the tracking code loads if the function is pushed to _hsp before the tracking code loads.If the banner is enabled, the callback function will be called when the visitor clicks on the accept or decline button. JavaScript// Log the consent status of the current visitor to the consolevar _hsp = (window._hsp = window._hsp || []);_hsp.push(["addPrivacyConsentListener", function (consent) { if (consent.allowed) { console.log('something') }}])The callbackFunction accepts a consent object as its only argument.The consent object has a single allowed property that will be true if:The cookie consent banner is not enabled, or is enabled in notify-only mode.The visitor clicks accept on the banner when opt-in mode is enabled.The visitor has previously clicked accept on the banner when opt-in mode is enabled.The property will be false if the consent banner is enabled in opt-in mode and the visitor clicks or has previously clicked the decline button.Enable website visitors to manage their consentCall the showBanner function to resurface the banner, enabling website visitors to make changes to their consent preferences. For example:JavaScriptvar _hsp = window._hsp = window._hsp || [];_hsp.push(['showBanner']);The behavior ofshowBannervaries by policy and is only available for Opt-In and Cookie-By-Category policies. For Opt-In policies, calling showBanner will cause the banner to reappear, as shown in the video below: For Cookies-By-Category policies, calling showBanner will cause the modal for selecting each category to reappear, as shown in the video below:UI ExamplesThis functionality can be made available to visitors in the form of buttons/links on your website that they can use to re-open the banner and edit their preferences. The following are examples with code. ButtonA button, often placed in the website footer.HTMLCSS Fixed position buttonA button with fixed positioning on the bottom of the screen. This kind of button has the advantage of being readily available and easy to find, while being somewhat obtrusive UX.HTMLCSS LinkA link or highlighted text.HTMLCSS Cookie Settings Block third party cookies manuallyThe HubSpot Consent Banner supports manual handling of third party tracking technologies and cookies. It's recommended to use manual handling if you have a complicated website and/or a dedicated web developer. If auto-blocking does not work for your site, manual blocking is also a good option.Manual blocking is implemented through the Cookie Banner Consent Listener API. This API is used to prevent tracking technologies from running until they have consent. To get started, take a look at the examples below.General usageIf you want to install a tracking script onto your website to display targeted ads to visitors. You could use something like the below:When this script is pasted into the head HTML of a page on a website it would run anytime someone visits that page, regardless of their consent status. Visitors will have cookies placed on their browser without consent.To prevent the script from running without consent, you can use the HubSpot Cookie Banner Consent Listener API to install the script when the visitor has consented to its cookies. Consent listeners are functions that run whenever the visitor submits their consent. To use this functionality, a consent listener needs to be created that adds the script to the page if the visitor has consented to advertisement cookies.JavaScriptThis script will register the consent listener with the cookie banner. When consent to cookies is submitted, the consent listener will run, adding HubSpot's third party ads script to the page.Example: Google TagGoogle Tag or gtag.js can be used to add Google Analytics. For example:JavaScriptTo load Google Analytics when analytics consent has been given, the gtag script needs to be added when consent is given:JavaScriptExample: HotJarHotJar is another example of analytics tracking. For example:JavaScriptTo ensure Hotjar runs when analytics consent is given, the consent listener can be added.JavaScriptImplement Google Consent Mode v2 manually
Gerelateerde documentatie
- Home Analytics & Events Cookie bannerCookie consent banner APISuper admins and users with permission to edit website settings can customize visitor cookie tracking and consent banners to comply with EU cookie laws and the General Data Protection Regulation (GDPR).A cookie consent banner allows visitors to opt in or opt out of being tracked in your HubSpot account with cookies. This feature works for all HubSpot pages as well as any external pages with your HubSpot tracking code installed. Customize the cookie tracking settings and cookie consent banner.In this article, learn how to manage the cookies that are added to a visitor's browser through the cookie consent banner.Remove cookies_hsp.push(['revokeCookieConsent']);Remove the cookies created by the HubSpot tracking code that are included in the consent banner under GDPR, include the HubSpot cookies related to tracking the visitor. As a result of the cookies being removed, the visitor would see the cookie consent banner on their next page load, as they would appear as a new visitor.This function does not remove cookies placed by non-HubSpot banners. You can find the specific list of cookies that will be removed on HubSpot's Knowledge Base. If cookie blocking is turned on, this function will revoke consent so any third-party cookies will not be updated or dropped during future visits to the website. JavaScript/*Example code to remove the consent banner cookieswhen a visitor clicks an element with the 'removeCookies' id.*/var _hsp = window._hsp = window._hsp || [];document.getElementById("removeCookies").onclick = function() { _hsp.push(['revokeCookieConsent']);};Place do not track cookie_hsq.push(['doNotTrack']);Places the __hs_do_not_track cookie in the visitors browser, which will prevent the HubSpot tracking code from sending any information for the visitor.You can remove the cookie by calling the function again and including the {track: true} argument:_hsq.push(['doNotTrack', {track: true}]);Please note: this function prevents all information from being collected by the tracking code, including anonymized traffic and custom event data.JavaScript/*Example code to place the __hs_do_not_track cookie forthe visitor when they click an element with the 'doNotTrack' id.*/document.getElementById("doNotTrack").onclick = function() { _hsq.push(['doNotTrack']);};Get privacy consent status_hsp.push(['addPrivacyConsentListener', callbackFunction]);Get the privacy consent status of the current visitor. There are 3 categories of consent that can be used to provide more granular control to the user. These each have their own keys within the consent.categories object:consent.categories.analyticsconsent.categories.advertisementconsent.categories.functionalityThe callbackFunction will be called, depending on the state of the page:If the banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline:the callbackFunction will be called immediately if the banner code is already loaded.the callbackFunction will be called after the tracking code loads if the function is pushed to _hsp before the tracking code loads.If the banner is enabled, the callback function will be called when the visitor clicks on the accept or decline button. JavaScript// Log the analytics category consent status of the current visitor to the consolevar _hsp = window._hsp = window._hsp || [];// analytics_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.analytics); }]);// advertisement_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.advertisement); }]);// functionality_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(consent.categories.functionality); }]);// or it can all be done in one call_hsp.push(['addPrivacyConsentListener', function(consent) { console.log(`analytics: ${consent.categories.analytics}`); console.log(`advertisement: ${consent.categories.advertisement}`); console.log(`functionality: ${consent.categories.functionality}`); }]);Cookies not by categoryPlease note: This is provided for backward compatibility with older scripts. For all new websites you should use the cookies by category method, giving more granular control over cookie activation._hsp.push(['addPrivacyConsentListener', callbackFunction]);Allows you to get the true or false privacy consent status of the current visitor.The callbackFunction will be called, depending on the state of the page:If the banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline:the callbackFunction will be called immediately if the banner code is already loaded.the callbackFunction will be called after the tracking code loads if the function is pushed to _hsp before the tracking code loads.If the banner is enabled, the callback function will be called when the visitor clicks on the accept or decline button. JavaScript// Log the consent status of the current visitor to the consolevar _hsp = (window._hsp = window._hsp || []);_hsp.push(["addPrivacyConsentListener", function (consent) { if (consent.allowed) { console.log('something') }}])The callbackFunction accepts a consent object as its only argument.The consent object has a single allowed property that will be true if:The cookie consent banner is not enabled, or is enabled in notify-only mode.The visitor clicks accept on the banner when opt-in mode is enabled.The visitor has previously clicked accept on the banner when opt-in mode is enabled.The property will be false if the consent banner is enabled in opt-in mode and the visitor clicks or has previously clicked the decline button.Enable website visitors to manage their consentCall the showBanner function to resurface the banner, enabling website visitors to make changes to their consent preferences. For example:JavaScriptvar _hsp = window._hsp = window._hsp || [];_hsp.push(['showBanner']);The behavior ofshowBannervaries by policy and is only available for Opt-In and Cookie-By-Category policies. For Opt-In policies, calling showBanner will cause the banner to reappear, as shown in the video below: For Cookies-By-Category policies, calling showBanner will cause the modal for selecting each category to reappear, as shown in the video below:UI ExamplesThis functionality can be made available to visitors in the form of buttons/links on your website that they can use to re-open the banner and edit their preferences. The following are examples with code. ButtonA button, often placed in the website footer.HTMLCSS Fixed position buttonA button with fixed positioning on the bottom of the screen. This kind of button has the advantage of being readily available and easy to find, while being somewhat obtrusive UX.HTMLCSS LinkA link or highlighted text.HTMLCSS Cookie Settings Block third party cookies manuallyThe HubSpot Consent Banner supports manual handling of third party tracking technologies and cookies. It's recommended to use manual handling if you have a complicated website and/or a dedicated web developer. If auto-blocking does not work for your site, manual blocking is also a good option.Manual blocking is implemented through the Cookie Banner Consent Listener API. This API is used to prevent tracking technologies from running until they have consent. To get started, take a look at the examples below.General usageIf you want to install a tracking script onto your website to display targeted ads to visitors. You could use something like the below:When this script is pasted into the head HTML of a page on a website it would run anytime someone visits that page, regardless of their consent status. Visitors will have cookies placed on their browser without consent.To prevent the script from running without consent, you can use the HubSpot Cookie Banner Consent Listener API to install the script when the visitor has consented to its cookies. Consent listeners are functions that run whenever the visitor submits their consent. To use this functionality, a consent listener needs to be created that adds the script to the page if the visitor has consented to advertisement cookies.JavaScriptThis script will register the consent listener with the cookie banner. When consent to cookies is submitted, the consent listener will run, adding HubSpot's third party ads script to the page.Example: Google TagGoogle Tag or gtag.js can be used to add Google Analytics. For example:JavaScriptTo load Google Analytics when analytics consent has been given, the gtag script needs to be added when consent is given:JavaScriptExample: HotJarHotJar is another example of analytics tracking. For example:JavaScriptTo ensure Hotjar runs when analytics consent is given, the consent listener can be added.JavaScriptImplement Google Consent Mode v2 manually