Adroll privacy consent using HubSpot's cookie permissions notification.

Hi there,

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).

It seems that this is the solution we need to get things running: https://developers.hubspot.com/docs/methods/tracking_code_api/get_consent_status

But we have no idea how to implement this!

Is anyone able to assist please? And example of our tracking code from Adroll would be the following:

<
script type = “text/javascript” > adroll_adv_id = “PROFILEID”;
adroll_pix_id = “PROFILEID”;
(function() {
var _onload = function() {
if (document.readyState && !/loaded|complete/.test(document.readyState)) {
setTimeout(_onload, 10);
return
}
if (!window.__adroll_loaded) {
__adroll_loaded = true;
setTimeout(_onload, 50);
return
}
var scr = document.createElement(“script”);
var host = ((“https:” == document.location.protocol) ? “https://s.adroll.com” : “http://a.adroll.com”);
scr.setAttribute(‘async’, ‘true’);
scr.type = “text/javascript”;
scr.src=host + “/j/roundtrip.js”;
((document.getElementsByTagName(‘head’) || [null])[0] || document.getElementsByTagName(‘script’)[0].parentNode).appendChild(scr);
};
if (window.addEventListener) {
window.addEventListener(‘load’, _onload, false);
} else {
window.attachEvent(‘onload’, _onload)
}
}()); < /script>

Any help would be much appreciated, thank you! :slightly_smiling_face:

Hi @gio-nab

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 hope this helps!

Hi Matthew,

Very helpful reply, thank you!

As someone who doesn’t really know Javascript very well at all, is the edit that needs to be made to the Adroll tracking code fairly simple?

(if so, is that something you could help with please?)

Thank you!

Hi @gio-nab

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.