1;(function () { 2 // AppsFlyer OneLink for CTA blocks (prime, promo-cta): build the OneLink from URL 3 // params and inject it into the buttons, only after marketing-cookie consent (Cookiebot). 4 // Without consent (or on SDK failure) the block's original hrefs stay as fallback. 5 6 var SMART_SCRIPT_SRC = 'https://onelinksmartscript.appsflyersdk.com/onelink-smart-script-latest.js' 7 // Block-agnostic: prime marks its button with data-af-btn; promo-cta uses its own class. 8 var BUTTON_SELECTOR = 'a[data-af-btn], a.auth-platforms__button' 9 var CLICK_EVENT = 'promo_cta_click' 10 11 var oneLinksApplied = false 12 var smartScriptLoading = false 13 14 function ctaSections() { 15 return document.querySelectorAll('[data-af-cta][data-af-onelink]') 16 } 17 18 function forEach(list, fn) { 19 Array.prototype.forEach.call(list, fn) 20 } 21 22 function hasMarketingConsent() { 23 return !!(window.Cookiebot && window.Cookiebot.consent && window.Cookiebot.consent.marketing) 24 } 25 26 function loadSmartScript(cb) { 27 if (window.AF_SMART_SCRIPT) { cb(); return } 28 if (smartScriptLoading) return 29 smartScriptLoading = true 30 31 var s = document.createElement('script') 32 s.src = SMART_SCRIPT_SRC 33 s.async = true 34 s.onload = function () { smartScriptLoading = false; cb() } 35 s.onerror = function () { smartScriptLoading = false } // keep fallback hrefs 36 document.head.appendChild(s) 37 } 38 39 function buildClickURL(oneLinkURL) { 40 if (!window.AF_SMART_SCRIPT || !oneLinkURL) return null 41 42 var result = window.AF_SMART_SCRIPT.generateOneLinkURL({ 43 oneLinkURL: oneLinkURL, 44 afParameters: { 45 mediaSource: { keys: ['utm_source'], overrideValues: { adwords: 'google_web' }, defaultValue: 'google_web' }, 46 campaign: { keys: ['utm_campaign'], defaultValue: 'web' }, 47 ad: { keys: ['utm_ad'], defaultValue: '%7Bcreative%7D' }, 48 adSet: { keys: ['utm_adset'], defaultValue: '%7Bplacement%7D' }, 49 afSub1: { keys: ['googleClickIdKey'] }, 50 afCustom: [ { paramKey: 'af_ss_ui', defaultValue: 'true' } ] 51 } 52 }) 53 54 return result && result.clickURL ? result.clickURL : null 55 } 56 57 function applyOneLinks() { 58 if (oneLinksApplied) return 59 var sections = ctaSections() 60 if (!sections.length) return 61 62 loadSmartScript(function () { 63 forEach(sections, function (section) { 64 var oneLinkURL = section.getAttribute('data-af-onelink') 65 var clickURL = buildClickURL(oneLinkURL) 66 if (!clickURL) return 67 forEach(section.querySelectorAll(BUTTON_SELECTOR), function (btn) { 68 btn.setAttribute('href', clickURL) 69 }) 70 }) 71 oneLinksApplied = true 72 }) 73 } 74 75 // Click signal for GTM/GA (not gated here; GTM enforces its own consent). 76 function trackClicks() { 77 forEach(ctaSections(), function (section) { 78 forEach(section.querySelectorAll(BUTTON_SELECTOR), function (btn) { 79 btn.addEventListener('click', function () { 80 if (window.dataLayer && typeof window.dataLayer.push === 'function') { 81 window.dataLayer.push({ event: CLICK_EVENT, cta_text: (btn.textContent || '').trim() }) 82 } 83 }) 84 }) 85 }) 86 } 87 88 function onConsent() { 89 if (hasMarketingConsent()) applyOneLinks() 90 } 91 92 function init() { 93 if (!ctaSections().length) return 94 95 trackClicks() 96 onConsent() 97 98 window.addEventListener('CookiebotOnAccept', onConsent) 99 window.addEventListener('CookiebotOnConsentReady', onConsent) 100 } 101 102 document.addEventListener('DOMContentLoaded', init) 103})()
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.