We’ve got HubSpot’s cookie notification enabled, and our ad platform Adroll won’t run without knowing that the user has given cookie tracking consent (for GDPR reasons).
This is a simple callback function that can be placed on your site where you’re looking to check if cookie consent has ever been set via the privacy policy consent banner.
As we can see in the documentation, this callback function works whereby, if the privacy policy consent banner is not enabled, or if the visitor has previously seen the banner and clicked accept or decline, the callbackFunction will be called as soon as the function is processed (immediately if the tracking code is already loaded, or after the tracking code finishes loading if the function is pushed to _hsq before the tracking code is loaded).
Else, if the consent banner is enabled, the callbackFunction will be called when the visitor clicks on the accept or decline button.
In this case, we can simply place this as a script on the page where you’re looking to have this callback function load and it will work with the Tracking Code as outlined above.
As an example of how this looks when embedded, I have added this to my page by simply adding the following code:
<script type="text/javascript">
_hsq.push(['addPrivacyConsentListener', function(consent) {
console.log("Current consent status is: " + consent.allowed);
}]);
</script>
Once this is working, it will return either a True or False value depending on the criteria outlined in the documentation.
Once this value is obtained, you will then be able to add in some additional code that allows you to execute this script you’ve linked based off of the status that is returned by this callbackFunction.
I am not 100% familiar with this script you’re using and it’s requirements and so cannot speak to how easy or complex this process would be. This does unfortunately fall outside of what I would be able to assist with as we avoid doing custom work incase an issue should arise.
In this scenario, we’d recommend partnering with a Developer if this is beyond your current skillset to ensure this is added correctly to your site and functions as you require it to.