PageSourceSearch

https://www.seomanagment.com/wp-content/plugins/cookiebox-gdprccpa…/js/cookieboxs-consent-mode.js?ver=3.4.0

js seomanagment.com collected 2026-10-07 22:18:55 UTC 32,856 bytes, 711 lines download raw bytes

1/**
2 * CookieBoxs - Consent Mode & Integrations
3 *
4 * This file handles Google Consent Mode v2 setup and third-party
5 * integration loading. All user-configured values are read from
6 * wp_localize_script objects:
7 *   - cookieboxsGcm          (consent mode config)
8 *   - cookieboxsIntegrations  (integration IDs)
9 *   - cookieboxsEnabled       (which integrations are active)
10 *
11 * Third-party integration snippets included below are standard embed
12 * scripts provided by each service for website integration. Source URLs:
13 *   - Google Tag Manager: https://developers.google.com/tag-platform/tag-manager/web
14 *   - Meta Pixel: https://developers.facebook.com/docs/meta-pixel/get-started
15 *   - TikTok Pixel: https://ads.tiktok.com/help/article/get-started-pixel
16 *   - Microsoft Clarity: https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-setup
17 *   - Hotjar: https://help.hotjar.com/hc/en-us/articles/115011639927
18 *   - Heap Analytics: https://developers.heap.io/docs/web
19 *   - Mixpanel: https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript
20 *   - PostHog: https://posthog.com/docs/libraries/js
21 *   - LinkedIn Insight Tag: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/insight-tag
22 *   - Pinterest Tag: https://help.pinterest.com/en/business/article/install-the-pinterest-tag
23 *   - Snapchat Pixel: https://businesshelp.snapchat.com/s/article/snap-pixel-about
24 *   - Twitter/X Pixel: https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites
25 *   - Microsoft Advertising UET: https://help.ads.microsoft.com/apex/index/3/en/56682
26 *   - LiveChat: https://developers.livechat.com/docs/getting-started/installing-livechat
27 *   - Crisp: https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/
28 *   - Tawk.to: https://help.tawk.to/article/adding-a-tawk-to-widget-to-your-website
29 *   - Intercom: https://developers.intercom.com/installing-intercom/web/installation
30 *   - Yandex Metrica: https://yandex.com/support/metrica/code/counter-initialize.html
31 *   - Matomo: https://developer.matomo.org/guides/tracking-javascript-guide
32 *
33 * @package CookieBoxs
34 */
35(function () {
36    'use strict';
37
38    /* === DataLayer & gtag bootstrap === */
39    window.dataLayer = window.dataLayer || [];
40    if (typeof window.gtag !== 'function') {
41        window.gtag = function () {
42            dataLayer.push(arguments);
43        };
44    }
45
46    /* If consent mode is disabled, just expose the state object and exit */
47    if (typeof cookieboxsGcm === 'undefined' || !cookieboxsGcm.enabled) {
48        window.cookieboxsConsentState = { analytics: false, marketing: false, functional: false };
49        return;
50    }
51
52    /* === Read consent cookie === */
53    function cbGetCookie(n) {
54        var v = document.cookie.match('(^|;)\\s*' + n + '\\s*=\\s*([^;]+)');
55        return v ? decodeURIComponent(v.pop()) : null;
56    }
57
58    var cookieboxsRaw = cbGetCookie('cookieboxs_consent');
59    var cookieboxsConsent = null;
60    if (cookieboxsRaw) {
61        try { cookieboxsConsent = JSON.parse(cookieboxsRaw); } catch (e) { /* invalid cookie */ }
62    }
63
64    /* === Granular (per-service) consent gate ===
65     * When the PRO granular feature is on, each integration is additionally
66     * gated by the visitor's per-service choice (consent.services). A service
67     * is allowed only when consent.services[key] is truthy. When granular is
68     * off — or the cookie predates the feature (no .services) — this returns
69     * true and the existing category gate alone decides. */
70    var cbGranularOn = (typeof cookieboxsGranular !== 'undefined') &&
71        (cookieboxsGranular.enabled === 'true' || cookieboxsGranular.enabled === true);
72    function cbServiceAllowed(key) {
73        if (!cbGranularOn) { return true; }
74        if (!cookieboxsConsent || !cookieboxsConsent.services) { return true; }
75        return !!cookieboxsConsent.services[key];
76    }
77
78    /* === Consent defaults === */
79    var cookieboxsAnalytics        = (cookieboxsConsent && cookieboxsConsent.analytics) ? 'granted' : cookieboxsGcm.defaultAnalytics;
80    var cookieboxsAds              = (cookieboxsConsent && cookieboxsConsent.marketing) ? 'granted' : cookieboxsGcm.defaultAds;
81    var cookieboxsAdUserData       = (cookieboxsConsent && cookieboxsConsent.marketing) ? 'granted' : cookieboxsGcm.defaultAdUserData;
82    var cookieboxsAdPersonalization = (cookieboxsConsent && cookieboxsConsent.marketing) ? 'granted' : cookieboxsGcm.defaultAdPersonalization;
83    var cookieboxsFunctional       = (cookieboxsConsent && cookieboxsConsent.functional) ? 'granted' : 'denied';
84
85    var cookieboxsConsentDefault = {
86        'analytics_storage':      cookieboxsAnalytics,
87        'ad_storage':             cookieboxsAds,
88        'ad_user_data':           cookieboxsAdUserData,
89        'ad_personalization':     cookieboxsAdPersonalization,
90        'functionality_storage':  cookieboxsFunctional,
91        'personalization_storage': cookieboxsAnalytics,
92        'security_storage':       'granted',
93        'wait_for_update':        500
94    };
95
96    if (cookieboxsGcm.region && cookieboxsGcm.region.length) {
97        cookieboxsConsentDefault.region = cookieboxsGcm.region;
98    }
99
100    gtag('consent', 'default', cookieboxsConsentDefault);
101
102    if (cookieboxsGcm.urlPassthrough) { gtag('set', 'url_passthrough', true); }
103    if (cookieboxsGcm.adsRedaction)   { gtag('set', 'ads_data_redaction', true); }
104
105    /* === Expose consent state for integrations & custom scripts === */
106    window.cookieboxsConsentState = {
107        analytics:  cookieboxsConsent && cookieboxsConsent.analytics,
108        marketing:  cookieboxsConsent && cookieboxsConsent.marketing,
109        functional: cookieboxsConsent && cookieboxsConsent.functional
110    };
111
112    /* ================================================================
113     * INTEGRATIONS
114     * All IDs come from cookieboxsIntegrations (JSON-encoded by wp_localize_script).
115     * cookieboxsEnabled flags indicate which integrations the admin has configured.
116     * ================================================================ */
117    if (typeof cookieboxsEnabled === 'undefined' || typeof cookieboxsIntegrations === 'undefined') {
118        return;
119    }
120
121    /* --- ALWAYS LOAD (respect consent mode internally) --- */
122
123    /* Google Tag Manager */
124    if (cookieboxsEnabled.gtm) {
125        (function (w, d, s, l, i) {
126            w[l] = w[l] || [];
127            w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
128            var f = d.getElementsByTagName(s)[0],
129                j = d.createElement(s),
130                dl = l != 'dataLayer' ? '&l=' + l : '';
131            j.async = true;
132            j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
133            f.parentNode.insertBefore(j, f);
134        })(window, document, 'script', 'dataLayer', cookieboxsIntegrations.gtm);
135    }
136
137    /* GA4 (if no GTM) — external script enqueued via wp_enqueue_script in PHP */
138    if (cookieboxsEnabled.ga4 && !cookieboxsEnabled.gtm && cbServiceAllowed('ga4')) {
139        gtag('js', new Date());
140        gtag('config', cookieboxsIntegrations.ga4);
141    }
142
143    /* Meta Pixel
144     * Source: https://developers.facebook.com/docs/meta-pixel/get-started */
145    if (cookieboxsEnabled.meta && cbServiceAllowed('meta')) {
146        !function (f, b, e, v, n, t, s) {
147            if (f.fbq) {
148                return;
149            }
150            n = f.fbq = function () {
151                n.callMethod
152                    ? n.callMethod.apply(n, arguments)
153                    : n.queue.push(arguments);
154            };
155            if (!f._fbq) {
156                f._fbq = n;
157            }
158            n.push = n;
159            n.loaded = !0;
160            n.version = '2.0';
161            n.queue = [];
162            t = b.createElement(e);
163            t.async = !0;
164            t.src = v;
165            s = b.getElementsByTagName(e)[0];
166            s.parentNode.insertBefore(t, s);
167        }(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
168        fbq('consent', window.cookieboxsConsentState && window.cookieboxsConsentState.marketing ? 'grant' : 'revoke');
169        fbq('init', cookieboxsIntegrations.meta);
170        fbq('track', 'PageView');
171    }
172
173    /* Google Ads — external script enqueued via wp_enqueue_script in PHP */
174    if (cookieboxsEnabled.gads && cbServiceAllowed('gads')) {
175        gtag('js', new Date());
176        gtag('config', cookieboxsIntegrations.gads);
177        if (cookieboxsEnabled.gadsLabel) {
178            gtag('event', 'conversion', { 'send_to': cookieboxsIntegrations.gads + '/' + cookieboxsIntegrations.gadsLabel });
179        }
180    }
181
182    /* TikTok Pixel
183     * Source: https://ads.tiktok.com/help/article/get-started-pixel */
184    if (cookieboxsEnabled.tiktok && cbServiceAllowed('tiktok')) {
185        !function (w, d, t) {
186            if (w.TiktokAnalyticsObject) {
187                return;
188            }
189            w.TiktokAnalyticsObject = t;
190            var ttq = w[t] = w[t] || [];
191            ttq.methods = [
192                'page', 'track', 'identify', 'instances', 'debug', 'on', 'off',
193                'once', 'ready', 'alias', 'group', 'enableCookie', 'disableCookie',
194                'holdConsent', 'revokeConsent', 'grantConsent'
195            ];
196            ttq.setAndDefer = function (t, e) {
197                t[e] = function () {
198                    t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
199                };
200            };
201            for (var i = 0; i < ttq.methods.length; i++) {
202                ttq.setAndDefer(ttq, ttq.methods[i]);
203            }
204            ttq.instance = function (t) {
205                for (var e = ttq._i[t] || [], n = 0; n < ttq.methods.length; n++) {
206                    ttq.setAndDefer(e, ttq.methods[n]);
207                }
208                return e;
209            };
210            ttq.load = function (e, n) {
211                var r = 'https://analytics.tiktok.com/i18n/pixel/events.js';
212                var o = n && n.partner;
213                ttq._i = ttq._i || {};
214                ttq._i[e] = [];
215                ttq._i[e]._u = r;
216                ttq._t = ttq._t || {};
217                ttq._t[e] = +new Date;
218                ttq._o = ttq._o || {};
219                ttq._o[e] = n || {};
220                n = d.createElement('script');
221                n.type = 'text/javascript';
222                n.async = !0;
223                n.src = r + '?sdkid=' + e + '&lib=' + t;
224                e = d.getElementsByTagName('script')[0];
225                e.parentNode.insertBefore(n, e);
226            };
227            ttq.load(cookieboxsIntegrations.tiktok);
228            if (window.cookieboxsConsentState && window.cookieboxsConsentState.marketing) {
229                ttq.grantConsent();
230            } else {
231                ttq.revokeConsent();
232            }
233            ttq.page();
234        }(window, document, 'ttq');
235    }
236
237    /* --- ANALYTICS (only if consent granted) --- */
238    if (window.cookieboxsConsentState && window.cookieboxsConsentState.analytics) {
239
240        /* Microsoft Clarity
241         * Source: https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-setup */
242        if (cookieboxsEnabled.clarity && cbServiceAllowed('clarity')) {
243            (function (c, l, a, r, i, t, y) {
244                c[a] = c[a] || function () {
245                    (c[a].q = c[a].q || []).push(arguments);
246                };
247                t = l.createElement(r);
248                t.async = 1;
249                t.src = 'https://www.clarity.ms/tag/' + i;
250                y = l.getElementsByTagName(r)[0];
251                y.parentNode.insertBefore(t, y);
252            })(window, document, 'clarity', 'script', cookieboxsIntegrations.clarity);
253        }
254
255        /* Hotjar
256         * Source: https://help.hotjar.com/hc/en-us/articles/115011639927 */
257        if (cookieboxsEnabled.hotjar && cbServiceAllowed('hotjar')) {
258            (function (h, o, t, j, a, r) {
259                h.hj = h.hj || function () {
260                    (h.hj.q = h.hj.q || []).push(arguments);
261                };
262                h._hjSettings = {
263                    hjid: parseInt(cookieboxsIntegrations.hotjar),
264                    hjsv: 6
265                };
266                a = o.getElementsByTagName('head')[0];
267                r = o.createElement('script');
268                r.async = 1;
269                r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
270                a.appendChild(r);
271            })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
272        }
273
274        /* Matomo
275         * Source: https://developer.matomo.org/guides/tracking-javascript-guide */
276        if (cookieboxsEnabled.matomo && cbServiceAllowed('matomo')) {
277            var _paq = window._paq = window._paq || [];
278            _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']);
279            (function () {
280                var u = cookieboxsIntegrations.matomoUrl;
281                _paq.push(['setTrackerUrl', u + 'matomo.php']);
282                _paq.push(['setSiteId', cookieboxsIntegrations.matomoId]);
283                var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
284                g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
285            })();
286        }
287
288        /* Yandex Metrica
289         * Source: https://yandex.com/support/metrica/code/counter-initialize.html */
290        if (cookieboxsEnabled.yandex && cbServiceAllowed('yandex')) {
291            (function (m, e, t, r, i, k, a) {
292                m[i] = m[i] || function () {
293                    (m[i].a = m[i].a || []).push(arguments);
294                };
295                m[i].l = 1 * new Date();
296                for (var j = 0; j < document.scripts.length; j++) {
297                    if (document.scripts[j].src === r) {
298                        return;
299                    }
300                }
301                k = e.createElement(t);
302                a = e.getElementsByTagName(t)[0];
303                k.async = 1;
304                k.src = r;
305                a.parentNode.insertBefore(k, a);
306            })(window, document, 'script', 'https://mc.yandex.ru/metrika/tag.js', 'ym');
307            ym(parseInt(cookieboxsIntegrations.yandex), 'init', {
308                clickmap: true,
309                trackLinks: true,
310                accurateTrackBounce: true
311            });
312        }
313
314        /* Heap Analytics
315         * Source: https://developers.heap.io/docs/web */
316        if (cookieboxsEnabled.heap && cbServiceAllowed('heap')) {
317            window.heap = window.heap || [];
318            heap.load = function (e, t) {
319                window.heap.appid = e;
320                window.heap.config = t = t || {};
321                var r = document.createElement('script');
322                r.type = 'text/javascript';
323                r.async = !0;
324                r.src = 'https://cdn.heapanalytics.com/js/heap-' + e + '.js';
325                var a = document.getElementsByTagName('script')[0];
326                a.parentNode.insertBefore(r, a);
327                var n = function (e) {
328                    return function () {
329                        heap.push([e].concat(Array.prototype.slice.call(arguments, 0)));
330                    };
331                };
332                var p = [
333                    'addEventProperties', 'addUserProperties', 'clearEventProperties',
334                    'identify', 'resetIdentity', 'removeEventProperty',
335                    'setEventProperties', 'track', 'unsetEventProperty'
336                ];
337                for (var o = 0; o < p.length; o++) {
338                    heap[p[o]] = n(p[o]);
339                }
340            };
341            heap.load(cookieboxsIntegrations.heap);
342        }
343
344        /* Mixpanel
345         * Source: https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript */
346        if (cookieboxsEnabled.mixpanel && cbServiceAllowed('mixpanel')) {
347            (function (f, b) {
348                if (!b.__SV) {
349                    var e, g, i, h;
350                    window.mixpanel = b;
351                    b._i = [];
352                    b.init = function (e, f, c) {
353                        function g(a, d) {
354                            var b = d.split('.');
355                            2 == b.length && (a = a[b[0]], d = b[1]);
356                            a[d] = function () {
357                                a.push([d].concat(Array.prototype.slice.call(arguments, 0)));
358                            };
359                        }
360                        var a = b;
361                        'undefined' !== typeof c ? a = b[c] = [] : c = 'mixpanel';
362                        a.people = a.people || [];
363                        a.toString = function (a) {
364                            var d = 'mixpanel';
365                            'mixpanel' !== c && (d += '.' + c);
366                            a || (d += ' (stub)');
367                            return d;
368                        };
369                        a.people.toString = function () {
370                            return a.toString(1) + '.people (stub)';
371                        };
372                        i = 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ');
373                        for (h = 0; h < i.length; h++) {
374                            g(a, i[h]);
375                        }
376                        var j = 'set set_once union unset remove delete'.split(' ');
377                        a.get_group = function () {
378                            function b(c) {
379                                d[c] = function () {
380                                    call2_args = arguments;
381                                    call2 = [c].concat(Array.prototype.slice.call(call2_args, 0));
382                                    a.push([e, call2]);
383                                };
384                            }
385                            for (
386                                var d = {},
387                                    e = ['get_group'].concat(Array.prototype.slice.call(arguments, 0)),
388                                    c = 0;
389                                c < j.length;
390                                c++
391                            ) {
392                                b(j[c]);
393                            }
394                            return d;
395                        };
396                        b._i.push([e, f, c]);
397                    };
398                    b.__SV = 1.2;
399                    e = f.createElement('script');
400                    e.type = 'text/javascript';
401                    e.async = !0;
402                    e.src = 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
403                    g = f.getElementsByTagName('script')[0];
404                    g.parentNode.insertBefore(e, g);
405                }
406            })(document, window.mixpanel || []);
407            mixpanel.init(cookieboxsIntegrations.mixpanel, { track_pageview: true });
408        }
409
410        /* PostHog
411         * Source: https://posthog.com/docs/libraries/js */
412        if (cookieboxsEnabled.posthog && cbServiceAllowed('posthog')) {
413            !function (t, e) {
414                var o, n, p, r;
415                e.__SV || (
416                    window.posthog = e,
417                    e._i = [],
418                    e.init = function (i, s, a) {
419                        function g(t, e) {
420                            var o = e.split('.');
421                            2 == o.length && (t = t[o[0]], e = o[1]);
422                            t[e] = function () {
423                                t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
424                            };
425                        }
426                        (p = t.createElement('script')).type = 'text/javascript';
427                        p.async = !0;
428                        p.src = s.api_host + '/static/array.js';
429                        (r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r);
430                        var u = e;
431                        for (
432                            void 0 !== a ? u = e[a] = [] : a = 'posthog',
433                            u.people = u.people || [],
434                            u.toString = function (t) {
435                                var e = 'posthog';
436                                return 'posthog' !== a && (e += '.' + a), t || (e += ' (stub)'), e;
437                            },
438                            u.people.toString = function () {
439                                return u.toString(1) + '.people (stub)';
440                            },
441                            o = 'capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys'.split(' '),
442                            n = 0;
443                            n < o.length;
444                            n++
445                        ) {
446                            g(u, o[n]);
447                        }
448                        e._i.push([i, s, a]);
449                    },
450                    e.__SV = 1
451                );
452            }(document, window.posthog || []);
453            posthog.init(cookieboxsIntegrations.posthog, {
454                api_host: cookieboxsIntegrations.posthogHost
455            });
456        }
457    }
458
459    /* --- MARKETING (only if consent granted) --- */
460    if (window.cookieboxsConsentState && window.cookieboxsConsentState.marketing) {
461
462        /* LinkedIn Insight Tag
463         * Source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/ads-reporting/insight-tag */
464        if (cookieboxsEnabled.linkedin && cbServiceAllowed('linkedin')) {
465            _linkedin_partner_id = cookieboxsIntegrations.linkedin;
466            window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
467            window._linkedin_data_partner_ids.push(_linkedin_partner_id);
468            (function (l) {
469                if (!l) {
470                    window.lintrk = function (a, b) {
471                        window.lintrk.q.push([a, b]);
472                    };
473                    window.lintrk.q = [];
474                }
475                var s = document.getElementsByTagName('script')[0];
476                var b = document.createElement('script');
477                b.type = 'text/javascript';
478                b.async = true;
479                b.src = 'https://snap.licdn.com/li.lms-analytics/insight.min.js';
480                s.parentNode.insertBefore(b, s);
481            })(window.lintrk);
482        }
483
484        /* Pinterest Tag
485         * Source: https://help.pinterest.com/en/business/article/install-the-pinterest-tag */
486        if (cookieboxsEnabled.pinterest && cbServiceAllowed('pinterest')) {
487            !function (e) {
488                if (!window.pintrk) {
489                    window.pintrk = function () {
490                        window.pintrk.queue.push(Array.prototype.slice.call(arguments));
491                    };
492                    var n = window.pintrk;
493                    n.queue = [];
494                    n.version = '3.0';
495                    var t = document.createElement('script');
496                    t.async = !0;
497                    t.src = e;
498                    var r = document.getElementsByTagName('script')[0];
499                    r.parentNode.insertBefore(t, r);
500                }
501            }('https://s.pinimg.com/ct/core.js');
502            pintrk('load', cookieboxsIntegrations.pinterest);
503            pintrk('page');
504        }
505
506        /* Snapchat Pixel
507         * Source: https://businesshelp.snapchat.com/s/article/snap-pixel-about */
508        if (cookieboxsEnabled.snapchat && cbServiceAllowed('snapchat')) {
509            (function (e, t, n) {
510                if (e.snaptr) {
511                    return;
512                }
513                var a = e.snaptr = function () {
514                    a.handleRequest
515                        ? a.handleRequest.apply(a, arguments)
516                        : a.queue.push(arguments);
517                };
518                a.queue = [];
519                var s = 'script';
520                r = t.createElement(s);
521                r.async = !0;
522                r.src = n;
523                var u = t.getElementsByTagName(s)[0];
524                u.parentNode.insertBefore(r, u);
525            })(window, document, 'https://sc-static.net/scevent.min.js');
526            snaptr('init', cookieboxsIntegrations.snapchat);
527            snaptr('track', 'PAGE_VIEW');
528        }
529
530        /* Twitter/X Pixel
531         * Source: https://business.x.com/en/help/campaign-measurement-and-analytics/conversion-tracking-for-websites */
532        if (cookieboxsEnabled.twitter && cbServiceAllowed('twitter')) {
533            !function (e, t, n, s, u, a) {
534                e.twq || (
535                    s = e.twq = function () {
536                        s.exe
537                            ? s.exe.apply(s, arguments)
538                            : s.queue.push(arguments);
539                    },
540                    s.version = '1.1',
541                    s.queue = [],
542                    u = t.createElement(n),
543                    u.async = !0,
544                    u.src = 'https://static.ads-twitter.com/uwt.js',
545                    a = t.getElementsByTagName(n)[0],
546                    a.parentNode.insertBefore(u, a)
547                );
548            }(window, document, 'script');
549            twq('config', cookieboxsIntegrations.twitter);
550        }
551
552        /* Bing/Microsoft Ads UET
553         * Source: https://help.ads.microsoft.com/apex/index/3/en/56682 */
554        if (cookieboxsEnabled.bing && cbServiceAllowed('bing')) {
555            (function (w, d, t, r, u) {
556                var f, n, i;
557                w[u] = w[u] || [];
558                f = function () {
559                    var o = {
560                        ti: cookieboxsIntegrations.bing,
561                        enableAutoSpaTracking: true
562                    };
563                    o.q = w[u];
564                    w[u] = new UET(o);
565                    w[u].push('pageLoad');
566                };
567                n = d.createElement(t);
568                n.src = r;
569                n.async = 1;
570                n.onload = n.onreadystatechange = function () {
571                    var s = this.readyState;
572                    s && s !== 'loaded' && s !== 'complete' || (f(), n.onload = n.onreadystatechange = null);
573                };
574                i = d.getElementsByTagName(t)[0];
575                i.parentNode.insertBefore(n, i);
576            })(window, document, 'script', '//bat.bing.com/bat.js', 'uetq');
577        }
578    }
579
580    /* --- FUNCTIONAL (only if consent granted) --- */
581    if (window.cookieboxsConsentState && window.cookieboxsConsentState.functional) {
582
583        /* Intercom
584         * Source: https://developers.intercom.com/installing-intercom/web/installation */
585        if (cookieboxsEnabled.intercom && cbServiceAllowed('intercom')) {
586            window.intercomSettings = {
587                api_base: 'https://api-iam.intercom.io',
588                app_id: cookieboxsIntegrations.intercom
589            };
590            (function () {
591                var w = window;
592                var ic = w.Intercom;
593                if (typeof ic === 'function') {
594                    ic('reattach_activator');
595                    ic('update', w.intercomSettings);
596                } else {
597                    var d = document;
598                    var i = function () {
599                        i.c(arguments);
600                    };
601                    i.q = [];
602                    i.c = function (args) {
603                        i.q.push(args);
604                    };
605                    w.Intercom = i;
606                    var l = function () {
607                        var s = d.createElement('script');
608                        s.type = 'text/javascript';
609                        s.async = true;
610                        s.src = 'https://widget.intercom.io/widget/' + cookieboxsIntegrations.intercom;
611                        var x = d.getElementsByTagName('script')[0];
612                        x.parentNode.insertBefore(s, x);
613                    };
614                    if (document.readyState === 'complete') {
615                        l();
616                    } else if (w.attachEvent) {
617                        w.attachEvent('onload', l);
618                    } else {
619                        w.addEventListener('load', l, false);
620                    }
621                }
622            })();
623        }
624
625        /* LiveChat
626         * Source: https://developers.livechat.com/docs/getting-started/installing-livechat */
627        if (cookieboxsEnabled.livechat && cbServiceAllowed('livechat')) {
628            window.__lc = window.__lc || {};
629            window.__lc.license = parseInt(cookieboxsIntegrations.livechat);
630            (function (n, t, c) {
631                function i(n) {
632                    return e._h ? e._h.apply(null, n) : e._q.push(n);
633                }
634                var e = {
635                    _q: [],
636                    _h: null,
637                    _v: '2.0',
638                    on: function () {
639                        i(['on', c.call(arguments)]);
640                    },
641                    once: function () {
642                        i(['once', c.call(arguments)]);
643                    },
644                    off: function () {
645                        i(['off', c.call(arguments)]);
646                    },
647                    get: function () {
648                        if (!e._h) {
649                            throw new Error('[LiveChatWidget] You can not use getters before load.');
650                        }
651                        return i(['get', c.call(arguments)]);
652                    },
653                    call: function () {
654                        i(['call', c.call(arguments)]);
655                    },
656                    init: function () {
657                        var n = t.createElement('script');
658                        n.async = !0;
659                        n.type = 'text/javascript';
660                        n.src = 'https://cdn.livechatinc.com/tracking.js';
661                        t.head.appendChild(n);
662                    }
663                };
664                !n.__lc.asyncInit && e.init();
665                n.LiveChatWidget = n.LiveChatWidget || e;
666            })(window, document, [].slice);
667        }
668
669        /* Crisp
670         * Source: https://docs.crisp.chat/guides/chatbox-sdks/web-sdk/ */
671        if (cookieboxsEnabled.crisp && cbServiceAllowed('crisp')) {
672            window.$crisp = []; window.CRISP_WEBSITE_ID = cookieboxsIntegrations.crisp;
673            (function () {
674                var d = document; var s = d.createElement('script');
675                s.src = 'https://client.crisp.chat/l.js'; s.async = 1;
676                d.getElementsByTagName('head')[0].appendChild(s);
677            })();
678        }
679
680        /* Tawk.to
681         * Source: https://help.tawk.to/article/adding-a-tawk-to-widget-to-your-website */
682        if (cookieboxsEnabled.tawkto && cbServiceAllowed('tawkto')) {
683            var Tawk_API = Tawk_API || {}, Tawk_LoadStart = new Date();
684            (function () {
685                var s1 = document.createElement('script'), s0 = document.getElementsByTagName('script')[0];
686                s1.async = true; s1.src = 'https://embed.tawk.to/' + cookieboxsIntegrations.tawkto + '/default';
687                s1.charset = 'UTF-8'; s1.setAttribute('crossorigin', '*');
688                s0.parentNode.insertBefore(s1, s0);
689            })();
690        }
691    }
692
693    /* === CUSTOM SCRIPTS (admin-entered, passed via wp_localize_script) === */
694    if (typeof cookieboxsCustomScripts !== 'undefined') {
695        var cookieboxsCats = ['necessary', 'functional', 'analytics', 'marketing'];
696        for (var ci = 0; ci < cookieboxsCats.length; ci++) {
697            var cookieboxsCat = cookieboxsCats[ci];
698            if (!cookieboxsCustomScripts[cookieboxsCat]) { continue; }
699            /* Necessary scripts run immediately; others require consent */
700            if (cookieboxsCat === 'necessary' || (window.cookieboxsConsentState && window.cookieboxsConsentState[cookieboxsCat])) {
701                try {
702                    var cookieboxsFn = new Function(cookieboxsCustomScripts[cookieboxsCat]);
703                    cookieboxsFn();
704                } catch (cbErr) {
705                    /* Silently skip broken custom scripts */
706                }
707            }
708        }
709    }
710
711})();

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.