HubSpot Cookie Consent – Control the use of non-HubSpot cookies on your website

The HubSpot Cookie Consent banner sets a cookie name ‘__hs_opt_out’ when you accept/decline the cookie consent.

You can make use of the status of the consent to remove/allow other cookies on your website, eg: google analytics.

We can get the status of the consent by adding a callback function to the ‘addPrivacyConsentListener’ event.

    //Add a listner to get the status of the consent banner
    _hsq.push(['addPrivacyConsentListener', function(consent) {
            if(consent.allowed) {
                alert("The user has accepted the use of cookies.");
            } else {
                alert("The user has declined the use of cookies.");
                //Remove other cookies here.
            }
    }]);

Leave a comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.