GDPR: addPrivacyConsentListener & revokeCookieConsent

Occasional Contributor

Our code in footer.php is

 

 

<script id="hs-script-loader" async defer src="https://js.hs-scripts.com/[Account-ID].js"></script>

 

How and where can I integrate the code?

 

1.)

 

// Log the consent status of the current visitor to the console
_hsq.push(['addPrivacyConsentListener', function(consent) {
        console.log(consent.allowed); 
    }]);

 

2.)

 

document.getElementById("removeCookies").onclick = function() {
    _hsq.push(['revokeCookieConsent']);
};

 

Thank you for your support. I'm not a programmer.

 

Thomas

 

P.S.: The cookie banner is already displayed correctly.

 

Reply
0 Upvotes
3 Replies 3
Community Manager

Hello @ThomasKujawa I don't completely understand your goal / question? Could you please elaborate further with detail / context of what you are trying to acheive? Thank you!

Reply
0 Upvotes
Occasional Contributor

I have the same question - I think at least...

 

Think of this scenario:

1. A new visitor comes to our website and the HubSpot populated cookie banner with I ACCEPT, I DECLINE buttons are shown.

2. Visitor accepts.

3. At a later time visitor decides that he/she no longer wants to be tracked.

 

The question is how do we go about using these APIs so that the visitor can by him/herself decline tracking. Can a CTA be used to trigger the script?

 

Ideally the logic would look like this:

...

if (CTA_opt-out == clicked)

  If (cookie tracking == TRUE)

    removeCookies();

    ShowDialog("You are no longer tracked. If you also want to remove your complete history, please read more on https://www.asdf.com/exercise-my-rights");

  else

    ShowDialog("You were never being tracked!");

...

Highlighted