1(() => { 2 const GOOGLE_ADS_ID = "AW-17212305185"; 3 const GA_MEASUREMENT_ID = "G-QWRF8GGZWD"; 4 const META_PIXEL_ID = "1863858521185859"; 5 const OPENAI_PIXEL_ID = "XQ881coH8jcXxKRWHdeqUQ"; 6 const OPENAI_PIXEL_SDK_URL = "https://bzrcdn.openai.com/sdk/oaiq.min.js"; 7 const META_EVENT_QUERY_PARAM = "meta_event"; 8 const META_EVENT_STORAGE_KEY = "mv_meta_event"; 9 const META_EVENT_NAME_BY_PARAM = { 10 lead: "Lead", 11 complete_registration: "CompleteRegistration", 12 }; 13 const loadedPartners = new Set(); 14 15 function addScript(src, properties = {}) { 16 const script = document.createElement("script"); 17 script.src = src; 18 Object.entries(properties).forEach(([key, value]) => { 19 script[key] = value; 20 }); 21 document.head.appendChild(script); 22 return script; 23 } 24 25 function getConsentPreferences(preferences) { 26 if (preferences) return preferences; 27 if (window.cookieConsent && typeof window.cookieConsent.getPreferences === "function") { 28 return window.cookieConsent.getPreferences(); 29 } 30 return null; 31 } 32 33 function loadMetaPixelPageView() { 34 if (window.__motoankaufMetaPixelLoaded) return true; 35 36 !function(f,b,e,v,n,t,s) 37 {if(f.fbq)return;n=f.fbq=function(){n.callMethod? 38 n.callMethod.apply(n,arguments):n.queue.push(arguments)}; 39 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; 40 n.queue=[];t=b.createElement(e);t.async=!0; 41 t.src=v;s=b.getElementsByTagName(e)[0]; 42 s.parentNode.insertBefore(t,s)}(window, document,'script', 43 'https://connect.facebook.net/en_US/fbevents.js'); 44 fbq('init', META_PIXEL_ID); 45 fbq('track', 'PageView'); 46 window.__motoankaufMetaPixelLoaded = true; 47 return true; 48 } 49 50 function loadOpenAiPixel() { 51 if (window.__motoankaufOpenAiPixelLoaded) return true; 52 if (typeof window.oaiq === "function") { 53 window.__motoankaufOpenAiPixelLoaded = true; 54 return true; 55 } 56 57 !function(w,d,s,u){if(w.oaiq)return;var q=function(){q.q.push(arguments)};q.q=[];w.oaiq=q;var j=d.createElement(s);j.async=1;j.src=u;var f=d.getElementsByTagName(s)[0];f.parentNode.insertBefore(j,f)}(window,document,"script",OPENAI_PIXEL_SDK_URL); 58 59 if (typeof window.oaiq !== "function") return false; 60 window.oaiq("init", { pixelId: OPENAI_PIXEL_ID, debug: true }); 61 window.__motoankaufOpenAiPixelLoaded = true; 62 return true; 63 } 64 65 function isOpenAiConsentBypassPath() { 66 try { 67 const pathname = new URL(window.location.href).pathname.replace(/\/+$/, "") || "/"; 68 return pathname === "/vielen-dank"; 69 } catch (error) { 70 return false; 71 } 72 } 73 74 function measureOpenAiRegistrationCompleted() { 75 if (window.__motoankaufOpenAiRegistrationCompletedMeasured) return false; 76 if (!loadOpenAiPixel() || typeof window.oaiq !== "function") return false; 77 78 window.oaiq("measure", "registration_completed", { type: "customer_action" }); 79 window.__motoankaufOpenAiRegistrationCompletedMeasured = true; 80 return true; 81 } 82 83 function normalizeMetaEventName(rawValue) { 84 const eventKey = String(rawValue || "").trim().toLowerCase(); 85 return META_EVENT_NAME_BY_PARAM[eventKey] || ""; 86 } 87 88 function getMetaEventFromStorage() { 89 try { 90 return normalizeMetaEventName(window.sessionStorage.getItem(META_EVENT_STORAGE_KEY)); 91 } catch (error) { 92 return ""; 93 } 94 } 95 96 function getMetaEventFromUrl() { 97 try { 98 const url = new URL(window.location.href); 99 return normalizeMetaEventName(url.searchParams.get(META_EVENT_QUERY_PARAM)); 100 } catch (error) { 101 return ""; 102 } 103 } 104 105 // The Meta event for the thank-you page is carried via sessionStorage so the 106 // address bar stays clean (e.g. /vielen-dank). The legacy URL parameter is kept 107 // only as a fallback for no-JS / older entry points. 108 function getMetaEventSignal() { 109 return getMetaEventFromStorage() || getMetaEventFromUrl(); 110 } 111 112 function clearMetaEventSignal() { 113 try { 114 window.sessionStorage.removeItem(META_EVENT_STORAGE_KEY); 115 } catch (error) { 116 // Ignore storage failures. 117 } 118 try { 119 const url = new URL(window.location.href); 120 if (url.searchParams.has(META_EVENT_QUERY_PARAM)) { 121 url.searchParams.delete(META_EVENT_QUERY_PARAM); 122 const nextUrl = url.pathname + url.search + url.hash; 123 window.history.replaceState(window.history.state, "", nextUrl); 124 } 125 } catch (error) { 126 // Keep the URL unchanged when history manipulation is unavailable. 127 } 128 } 129 130 function trackMetaEventSignal() { 131 const eventName = getMetaEventSignal(); 132 if (!eventName) return false;
133 if (window.__motoankaufMetaQueryEventTracked) { 134 clearMetaEventSignal(); 135 return false; 136 } 137 if (!loadMetaPixelPageView() || typeof window.fbq !== "function") return false; 138 139 window.fbq("track", eventName); 140 window.__motoankaufMetaQueryEventTracked = true; 141 clearMetaEventSignal(); 142 return true; 143 } 144 145 const partnerLoaders = { 146 google_tag_manager() { 147 ((windowObject, documentObject, tagName, layerName, gtmId) => { 148 windowObject[layerName] = windowObject[layerName] || []; 149 windowObject[layerName].push({ 150 "gtm.start": new Date().getTime(), 151 event: "gtm.js", 152 }); 153 154 const firstScript = documentObject.getElementsByTagName(tagName)[0]; 155 const script = documentObject.createElement(tagName); 156 script.async = true; 157 script.src = `https://www.googletagmanager.com/gtm.js?id=${gtmId}`; 158 firstScript.parentNode.insertBefore(script, firstScript); 159 })(window, document, "script", "dataLayer", "GTM-5RXG6RRF"); 160 161 (() => { 162 const template = document.getElementById("gtm-noscript-template"); 163 if (!template) return; 164 if (document.getElementById("gtm-noscript-frame")) return; 165 const clone = template.content.cloneNode(true); 166 document.body.prepend(clone); 167 })(); 168 }, 169 170 google_analytics_ads() { 171 function gtag() { 172 window.dataLayer.push(arguments); 173 } 174 175 if (window.dataLayer === undefined) { 176 window.dataLayer = []; 177 } 178 179 window.gtag = gtag; 180 addScript(`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ADS_ID}`, { 181 async: true, 182 }); 183 addScript(`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`, { 184 async: true, 185 }); 186 187 gtag("js", new Date()); 188 gtag("config", GOOGLE_ADS_ID); 189 gtag("config", GA_MEASUREMENT_ID); 190 }, 191 192 meta_pixel() { 193 const loaded = loadMetaPixelPageView(); 194 trackMetaEventSignal(); 195 return loaded; 196 }, 197 198 openai_pixel() { 199 return loadOpenAiPixel(); 200 }, 201 202 youtube_embed() { 203 addScript("https://cdn.jsdelivr.net/npm/@justinribeiro/lite-youtube@1/lite-youtube.min.js", { 204 type: "module", 205 }); 206 }, 207 }; 208 209 function loadThirdPartyScripts(preferences) { 210 const consentPreferences = getConsentPreferences(preferences); 211 if (!consentPreferences || !consentPreferences.partners) return; 212 213 Object.entries(consentPreferences.partners).forEach(([partnerId, allowed]) => { 214 if (!allowed || loadedPartners.has(partnerId)) return; 215 216 const loader = partnerLoaders[partnerId]; 217 if (typeof loader !== "function") return; 218 219 loader(); 220 loadedPartners.add(partnerId); 221 }); 222 } 223 224 window.gtag_report_conversion = function (url, transactionId) { 225 if (typeof window.gtag !== "function") return false; 226 227 const eventParams = { 228 send_to: "AW-17212305185/6SEICLf1-OscEKHeu49A", 229 value: 1.0, 230 currency: "PLN", 231 event_callback() { 232 if (url !== undefined) { 233 window.location = url; 234 } 235 }, 236 }; 237 const normalizedTransactionId = 238 typeof transactionId === "string" ? transactionId.trim() : ""; 239 if (normalizedTransactionId) { 240 eventParams.transaction_id = normalizedTransactionId; 241 } 242 243 window.gtag("event", "conversion", eventParams); 244 console.info("[motoankauf] Google Ads conversion event", { 245 send_to: eventParams.send_to,
246 value: eventParams.value, 247 currency: eventParams.currency, 248 transaction_id: eventParams.transaction_id || null, 249 }); 250 251 return false; 252 }; 253 254 window.trackMetaEvent = function (eventName, params = {}) { 255 if (!eventName || typeof window.fbq !== "function") return false; 256 window.fbq("track", eventName, params); 257 return true; 258 }; 259 260 window.trackMetaLead = function (params = {}) { 261 return window.trackMetaEvent("Lead", params); 262 }; 263 264 window.trackMetaCompleteRegistration = function (params = {}) { 265 return window.trackMetaEvent("CompleteRegistration", params); 266 }; 267 268 window.loadMetaPixelForFinalFormStep = function () { 269 return loadMetaPixelPageView(); 270 }; 271 272 document.addEventListener("cookie-consent-changed", (event) => { 273 if (event.detail && event.detail.preferences) { 274 loadThirdPartyScripts(event.detail.preferences); 275 } 276 }); 277 278 loadThirdPartyScripts(); 279 280 // Consent bypass: initialize OpenAI Pixel only on the German thank-you page, 281 // regardless of the visitor's openai_pixel preference. 282 if (isOpenAiConsentBypassPath()) { 283 measureOpenAiRegistrationCompleted(); 284 } 285 286 // Consent bypass: fire the Meta event signaled for the thank-you page (via 287 // sessionStorage or the legacy ?meta_event URL parameter) even when the visitor 288 // has not accepted the meta_pixel partner. This guarantees conversion tracking 289 // on dedicated thank-you pages regardless of consent state. 290 if (getMetaEventSignal()) { 291 trackMetaEventSignal(); 292 } 293})();
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.