1 2/////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////// 4/** 5 * RWI-0751 [BW] 2025-11-25 6 * Cookie Consent Controls 7 * @link https://cookieconsent.orestbida.com/ 8 */ 9 10 11 12/** 13 * Update gtag consent according to the users choices made in CookieConsent UI 14 */ 15function updateGtagConsent() { 16 console.log('updateGtagConsent'); 17 var analyticsGranted = CookieConsent.acceptedService(SERVICE_ANALYTICS_STORAGE, CAT_ANALYTICS); 18 gtag('consent', 'update', { 19 [SERVICE_ANALYTICS_STORAGE]: analyticsGranted ? 'granted' : 'denied', 20 [SERVICE_FUNCTIONALITY_STORAGE]: CookieConsent.acceptedService(SERVICE_FUNCTIONALITY_STORAGE, CAT_FUNCTIONALITY) ? 'granted' : 'denied', 21 [SERVICE_PERSONALIZATION_STORAGE]: CookieConsent.acceptedService(SERVICE_PERSONALIZATION_STORAGE, CAT_FUNCTIONALITY) ? 'granted' : 'denied', 22 // [SERVICE_SECURITY_STORAGE]: CookieConsent.acceptedService(SERVICE_SECURITY_STORAGE, CAT_SECURITY) ? 'granted' : 'denied', // grouped with strictly necessary cookies 23 }); 24 25 // Fire an immediate page_view after analytics consent is granted so GA realtime reflects activity right away. 26 if (analyticsGranted) { 27 gtag('event', 'page_view'); 28 } 29} 30 31/** 32 * All config. options available here: 33 * https://cookieconsent.orestbida.com/reference/configuration-reference.html 34 */ 35var cookieConsentConfigDefault = { 36 guiOptions: { 37 consentModal: { 38 layout: "bar", 39 position: "bottom", 40 equalWeightButtons: false, 41 flipButtons: true 42 }, 43 preferencesModal: { 44 layout: "box", 45 position: "right", 46 equalWeightButtons: false, 47 flipButtons: true 48 } 49 }, 50 51 // Trigger consent update when user choices change 52 onFirstConsent: () => { 53 updateGtagConsent(); 54 }, 55 onConsent: () => { 56 updateGtagConsent(); 57 }, 58 onChange: () => { 59 updateGtagConsent(); 60 }, 61 62 categories: { 63 [CAT_NECESSARY]: { 64 enabled: true, // this category is enabled by default 65 readOnly: true, // this category cannot be disabled 66 }, 67 [CAT_ANALYTICS]: { 68 enabled: true, 69 autoClear: { 70 cookies: [ 71 { 72 name: /^_ga/, // regex: match all cookies starting with '_ga' 73 }, 74 { 75 name: '_gid', // string: exact cookie name 76 } 77 ] 78 }, 79 // See: https://cookieconsent.orestbida.com/reference/configuration-reference.html#category-services 80 services: { 81 [SERVICE_ANALYTICS_STORAGE]: { 82 label: 'Enables storage (such as cookies) related to analytics e.g. visit duration.', 83 } 84 } 85 }, 86 [CAT_FUNCTIONALITY]: { 87 enabled: true, 88 services: { 89 [SERVICE_FUNCTIONALITY_STORAGE]: { 90 label: 'Enables storage that supports the functionality of the website or app e.g. language settings.', 91 }, 92 [SERVICE_PERSONALIZATION_STORAGE]: { 93 label: 'Enables storage related to personalization e.g. video recommendations.', 94 }, 95 } 96 } 97 }, 98 99 language: { 100 default: 'en', 101 translations: { 102 en: { 103 consentModal: { 104 title: 'This site uses cookies', 105 description: 'This website uses cookies necessary to ensure proper function and provide security, plus additional cookies for tracking and analytics. Additional cookies are not set unless you agree.', 106 acceptAllBtn: 'Accept all', 107 acceptNecessaryBtn: 'Reject all', 108 showPreferencesBtn: 'Manage Individual preferences' 109 }, 110 preferencesModal: { 111 title: 'Manage cookie preferences', 112 acceptAllBtn: 'Accept all',
113 acceptNecessaryBtn: 'Reject all', 114 savePreferencesBtn: 'Accept current selection', 115 closeIconLabel: 'Close modal', 116 sections: [ 117 { 118 title: "Cookie usage", 119 description: "This website uses cookies necessary to ensure proper function and provide security, plus additional cookies for tracking and analytics." 120 }, 121 { 122 title: "Strictly necessary cookies", 123 description: "These cookies are essential for the proper functioning of the website, as well as for security to authenticate users, prevent fraud, and protect users as they interact with a service.", 124 linkedCategory: CAT_NECESSARY, 125 }, 126 { 127 title: "Analytics", 128 description: 'Cookies used for analytics help collect data that allows services to understand how users interact with a particular service. The
128se insights allow services both to improve content and to build better features that improve the userâs experience.', 129 linkedCategory: CAT_ANALYTICS 130 }, 131 { 132 title: 'Functionality', 133 description: 'Cookies used for functionality allow users to interact with a service or site to access features that are fundamental to that service. Things considered fundamental to the service include preferences like the userâs choice of language, product optimizations that help maintain and improve a service, and maintaining information relating to a userâs session, such as the content of a shopping cart.', 134 linkedCategory: CAT_FUNCTIONALITY, 135 }, 136 { 137 title: 'More information', 138 description: 'For more information about cookies and your choices, please review our <a href="/privacy">privacy policy</a>.' 139 } 140 ] 141 } 142 } 143 } 144 } 145}; 146 147// cookieConsentConfig could be handed to us from the parent page, let's merge it with the default config 148// Merge cookieConsentConfig, if present, on top of the default config 149var cookieConsentConfigFinal; 150if (typeof cookieConsentConfig === 'object' && cookieConsentConfig !== null) { 151 // Deep merge helper 152 function deepMerge(target, source) { 153 for (var key in source) { 154 if ( 155 source.hasOwnProperty(key) && 156 source[key] !== null && 157 typeof source[key] === 'object' && 158 !Array.isArray(source[key]) 159 ) { 160 if (!target[key] || typeof target[key] !== 'object' || Array.isArray(target[key])) { 161 target[key] = {}; 162 } 163 deepMerge(target[key], source[key]); 164 } else { 165 target[key] = source[key]; 166 } 167 } 168 return target; 169 } 170 cookieConsentConfigFinal = deepMerge( 171 deepMerge({}, window._defaultCookieConsentConfig || cookieConsentConfigDefault || { 172 language: { 173 default: 'en', 174 translations: {/* fallback */} 175 } 176 }), 177 cookieConsentConfig 178 ); 179} else { 180 // Default 181 cookieConsentConfigFinal = window._defaultCookieConsentConfig || cookieConsentConfigDefault || cookieConsentConfig; 182} 183 184 185console.log('Running CookieConsent', cookieConsentConfigFinal); 186CookieConsent.run(cookieConsentConfigFinal); 187 188 189
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.