// 1. Ensure the HubSpot cookie banner queue exists var _hsp = window._hsp = window._hsp || []; // Global variable to keep track of consent status for custom click events var openAiConsentGranted = false; // 2. Register the HubSpot Privacy Consent Listener _hsp.push([ 'addPrivacyConsentListener', function (consent) { // Check if ALL primary tracking categories are explicitly set to true if (consent.categories && consent.categories.analytics && consent.categories.advertisement) { openAiConsentGranted = true; console.log("HubSpot Consent: All accepted. Firing ChatGPT Page View..."); // FIRE PAGE VIEW EVENT if (typeof oaiq === 'function') { oaiq("measure", "page_viewed", { type: "contents" }); } } else { openAiConsentGranted = false; console.log("HubSpot Consent: Directives not fully met or revoked."); } } ]); // 3. Example for Dealer Website Clicks // Wrap your existing click event handler with the openAiConsentGranted check function handleDealerClick() { if (openAiConsentGranted && typeof oaiq === 'function') { oaiq( "measure", "custom", { type: "custom" }, { custom_event_name: "click_dealer_website" } ); } else { console.log("Dealer click blocked: Consent not granted."); } }
Go to Top