The cookie consent banner enables you to enable/disable different analytics scripts based on user preferences.
_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.
The code block below provides an example of defining an event handler to remove cookies when the user clicks an element (like a button) with an id
of removeCookies
:
_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}]);
id
of removeCookies
:
_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.analytics
consent.categories.advertisement
consent.categories.functionality
_hsp
before the tracking code loads._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:
callbackFunction
accepts a consent
object as its only argument.
The consent
object has a single allowed
property that will be true
if:
false
if the consent banner is enabled in opt-in mode and the visitor clicks or has previously clicked the decline button.
showBanner
function to resurface the banner, enabling website visitors to make changes to their consent preferences. For example:
showBanner
varies 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:
<script src=”https://my.advertisement.script.com/ads”></script>
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.
Field name | Type | Description |
---|---|---|
analytics | Boolean | Grants consent to use cookies to gather analytics data from the website visitor. |
advertisement | Boolean | Grants consent to use cookies to help serve personalized ads to the visitor. |
functionality | Boolean | Grants consent to use cookies for required functionality for your website to function (e.g., authentication). |
true
.