From b82486ae758810ee9fac0f0a5687c35b375c8ea0 Mon Sep 17 00:00:00 2001 From: Ronnie Miller Date: Mon, 15 Sep 2025 13:26:00 -0700 Subject: [PATCH] Switch from Ketch to IBM TrustArc for cookie consent --- src/js/10-ketch-consent.js | 86 ----------------------------------- src/js/10-trustarc-consent.js | 23 ++++++++++ src/partials/head-scripts.hbs | 4 +- 3 files changed, 25 insertions(+), 88 deletions(-) delete mode 100644 src/js/10-ketch-consent.js create mode 100644 src/js/10-trustarc-consent.js diff --git a/src/js/10-ketch-consent.js b/src/js/10-ketch-consent.js deleted file mode 100644 index 6293ef55..00000000 --- a/src/js/10-ketch-consent.js +++ /dev/null @@ -1,86 +0,0 @@ -;(function () { - 'use strict' - - window.analytics.ready(() => { - window.ketch('once', 'consent', onKetchConsent) - window.ketch('on', 'consent', onKetchConsentGtagTrack) - window.ketch('on', 'userConsentUpdated', onKetchConsentUpdated) - }) - - // If the user is in the US-CA region, change the text of the preference center link - // 3/19/25: Disabled this feature due to shifting CA legal requirements. Will re-enable with new textContent if needed - // window.ketch('on', 'regionInfo', (regionInfo) => { - // const customTextRegions = ['US-CA'] - // if (customTextRegions.includes(regionInfo)) { - // const preferenceCenterLinkElement = document.getElementById('preferenceCenterLink') - // if (preferenceCenterLinkElement) { - // preferenceCenterLinkElement.textContent = 'Do Not Sell My Personal Information' - // } - // } - // }) - - // If the user is in the default jurisdiction, remove the preference center link - window.ketch('on', 'jurisdiction', (jurisdiction) => { - if (jurisdiction.includes('default')) { - const preferenceCenterContainerElement = document.getElementById('preferenceCenterContainer') - if (preferenceCenterContainerElement) { - preferenceCenterContainerElement.remove() - } - } - }) - - // Once - This will be fired only one time, will initialize all the main features. - const onKetchConsent = (consent) => { - window.ketchConsent = consent - addKetchConsentToContextMiddleware() - window.analytics.page() - // loadScripts(); // Load any script if we have scripts to fire after ketch consent is fired. - } - - // on - Each time the user changes the preferences, save them to the global variable - const onKetchConsentUpdated = (consent) => { - window.ketchConsent = consent - } - - // On - each time the consent is loaded, track it to the gtag event - const onKetchConsentGtagTrack = (consent) => { - if (window.gtag && - consent.purposes && - 'analytics' in consent.purposes && - 'targeted_advertising' in consent.purposes - ) { - const analyticsString = consent.purposes.analytics === true ? 'granted' : 'denied' - const targetedAdsString = consent.purposes.targeted_advertising === true ? 'granted' : 'denied' - - const gtagObject = { - analytics_storage: analyticsString, - ad_personalization: targetedAdsString, - ad_storage: targetedAdsString, - ad_user_data: targetedAdsString, - } - window.gtag('consent', 'update', gtagObject) - } - } - - // Use the analytics.addSourceMiddleware function to include the consent on all the events - const addKetchConsentToContextMiddleware = () => { - window.analytics.addSourceMiddleware(({ payload, next }) => { - if (window.ketchConsent) { - const analyticsString = window.ketchConsent.purposes.analytics === true ? 'granted' : 'denied' - const targetedAdsString = window.ketchConsent.purposes.targeted_advertising === true ? 'granted' : 'denied' - - payload.obj.properties = { - ...(payload.obj.properties || {}), - analyticsStorageConsentState: analyticsString, - adsStorageConsentState: targetedAdsString, - adUserDataConsentState: targetedAdsString, - adPersonalizationConsentState: targetedAdsString, - } - payload.obj.context.consent = { - categoryPreferences: window.ketchConsent?.purposes, - } - } - next(payload) - }) - } -})() diff --git a/src/js/10-trustarc-consent.js b/src/js/10-trustarc-consent.js new file mode 100644 index 00000000..ff996fe9 --- /dev/null +++ b/src/js/10-trustarc-consent.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +window._ibmAnalytics = { + "settings": { + "name": "DataStax", + "tealiumProfileName": "ibm-subsidiary", + }, + "trustarc": { + "privacyPolicyLink": "https://www.datastax.com/legal/datastax-website-privacy-policy" + }, + "digitalData.page.services.google.enabled": true +}; +window.digitalData = { + "page": { + "pageInfo": { + "ibm": { + "siteId": "IBM_" + _ibmAnalytics.settings.name, + } + }, + "category": { + "primaryCategory": "PC230" + } + } +}; diff --git a/src/partials/head-scripts.hbs b/src/partials/head-scripts.hbs index 9e543ddd..bea0d1b5 100644 --- a/src/partials/head-scripts.hbs +++ b/src/partials/head-scripts.hbs @@ -6,8 +6,8 @@ analytics.load("{{this}}"); {{/with}} -{{#with site.keys.ketchSmartTagUrl}} - +{{#with site.keys.ibmAnalyticsEnabled}} + {{/with}}