Hi everyone,
I’m experiencing an issue where Facebook and LinkedIn pixels are firing on my site before users have given consent. I’m using HubSpot’s native Ads Management integration to connect these platforms, along with Google Ads, and OneTrust CMP to manage user consent.
I followed the HubSpot Cookie Banner API documentation and implemented a script using _hsq.push([‘doNotTrack’]) to block all tracking by default, enabling it only after consent is granted. While Google Ads behaves as expected (does not fire until consent is granted), Facebook and LinkedIn pixels are still firing prematurely (https://js-eu1.hsadspixel.net/fb.js for Facebook and px.ads.linkedin.com for LinkedIn).
Has anyone successfully resolved this issue or used OneTrust CMP with HubSpot Ads Management to ensure all pixels respect consent?
here is my script for Onetrust :
"
<!-- OneTrust Cookies Consent Notice start for skillandyou.com -->
<script src=“https://cdn.cookielaw.org/scripttemplates/otSDKStub.js”
type=“text/javascript” charset=“UTF-8”
data-domain-script=“78232b22-5983-4ccb-ac52-a917af20b765”>
</script>
<script type=“text/javascript”>
// Initialize the HubSpot tracking array
var _hsq = _hsq || [];
_hsq.push([‘doNotTrack’]); // Default to “Do Not Track”
// Function to notify HubSpot about consent
function OptanonWrapper() {
if (OnetrustActiveGroups.includes(“C0004”)) { // Ensure C0004 matches your OneTrust group for tracking
// Inform HubSpot that consent is granted for tracking
_hsq.push([‘doNotTrack’, { track: true }]);
} else {
// Inform HubSpot that tracking should remain disabled
_hsq.push([‘doNotTrack’]);
}
}
// Listen for consent changes
document.addEventListener(‘OneTrustGroupsUpdated’, function() {
OptanonWrapper();
});
</script>
<!-- OneTrust Cookies Consent Notice end for skillandyou.com -->"
Any guidance would be greatly appreciated.
Thank you!