(function(w,d,n){ if (w.__gaiMetricLoaded) return; w.__gaiMetricLoaded = true; var endpoint = "/adm-metric.php?mode=collect"; var pixelEndpoint = "/adm-metric.php?mode=pixel"; var trackingKey = "site_bLQBnwMtZY7obFFdva8N5mGGdGEWkT4Mu5Cj0HBt"; var googleAdsKeys = ["gclid","gbraid","wbraid","gad_source","gclsrc","gad_campaignid","utm_source","utm_medium","utm_campaign","utm_content","utm_term","campaignid","adgroupid","feeditemid","extensionid","targetid","target_id","loc_interest_ms","loc_physical_ms","matchtype","network","device","device_type","devicemodel","creative","keyword","network_type","placement","target","adposition","sitelinkid","param1","param2","copy","ifmobile","ifnotmobile","ifsearch","ifcontent","ifpla","ifnotpla","random","aceid","adtype","merchant_id","product_channel","product_country","product_id","product_language","product_partition_id","store_code","hotelcenter_id","hotel_id","hotel_partition_id","campaign_id","ad_group_id","asset_id","asset_group_id","assetgroupid","ad_id","lpurl","escapedlpurl","unescapedlpurl","ignore"]; var sdkVersion = "2.0.0"; var schemaVersion = "metric-event-v2"; var startedAt = Date.now(); var visibleStartedAt = d.visibilityState === "visible" ? Date.now() : 0; var visibleMs = 0, maxScroll = 0, clickCount = 0, rageClickCount = 0, deadClickCount = 0, formSubmitCount = 0, inputChangeCount = 0, copyCount = 0, phoneClickCount = 0, emailClickCount = 0, outboundClickCount = 0, sequence = 0; var recentClicks = [], queue = [], flushTimer = null; var sentScrollThresholds = {}; var userAgentData = n.userAgentData ? {brands:n.userAgentData.brands || [], mobile:n.userAgentData.mobile, platform:n.userAgentData.platform || null} : null; var queueKey = "gai_metric_queue_" + trackingKey; var firstTouchKey = "gai_first_touch_" + trackingKey; function id(prefix){ return (prefix + "_" + Math.random().toString(36).slice(2) + Date.now().toString(36)).slice(0,128); } function getStore(key){ try { return w.localStorage.getItem(key) || w.sessionStorage.getItem(key); } catch(e) { return null; } } function setStore(key,value,sessionOnly){ try { (sessionOnly ? w.sessionStorage : w.localStorage).setItem(key,value); } catch(e) {} } function loadQueue(){ try { queue = JSON.parse(w.localStorage.getItem(queueKey) || "[]").slice(-100); } catch(e) { queue = []; } } function saveQueue(){ try { w.localStorage.setItem(queueKey, JSON.stringify(queue.slice(-100))); } catch(e) {} } var clientId = getStore("gai_client_id") || id("client"); var sessionId = getStore("gai_session_id") || id("session"); setStore("gai_client_id", clientId, false); setStore("gai_session_id", sessionId, true); loadQueue(); if (n.userAgentData && n.userAgentData.getHighEntropyValues) { try { n.userAgentData.getHighEntropyValues(["platform","platformVersion","architecture","model","bitness","fullVersionList","mobile"]) .then(function(values){ userAgentData = Object.assign(userAgentData || {}, values || {}); }) .catch(function(){}); } catch(e) {} } function allParams(){ var search = new URLSearchParams(w.location.search), all = {}; search.forEach(function(value,key){ if (key) all[key] = value; }); return all; } function storedFirstTouch(){ try { return JSON.parse(w.sessionStorage.getItem(firstTouchKey) || "null") || null; } catch(e) { return null; } } function hasAttributionParams(all){ if (all.gclid || all.gbraid || all.wbraid) return true; return googleAdsKeys.some(function(key){ return Object.prototype.hasOwnProperty.call(all,key); }); } function firstTouch(){ var current = allParams(), stored = storedFirstTouch(); if (!stored || (hasAttributionParams(current) && !stored.has_ad_params)) { stored = { has_ad_params: hasAttributionParams(current), first_landing_url: w.location.href, first_referrer: d.referrer || null, url_parameters: current, google_ads_parameters: googleAdsParams(current), captured_at: new Date().toISOString() }; try { w.sessionStorage.setItem(firstTouchKey, JSON.stringify(stored)); } catch(e) {} } return stored; } function googleAdsParams(all){ var out = {}; googleAdsKeys.forEach(function(key){ if (Object.prototype.hasOwnProperty.call(all,key)) out[key] = all[key]; }); return out; } function botSignals(){ var ua = n.userAgent || ""; return {webdriver: !!n.webdriver, headless_hint: /HeadlessChrome|PhantomJS|SlimerJS/i.test(ua), automation_hint: !!(w.callPhantom || w._phantom || w.__nightmare)}; } function fp(){ var raw = [n.userAgent||"", n.language||"", Intl.DateTimeFormat().resolvedOptions().timeZone||"", screen.width||0, screen.height||0, screen.colorDepth||0, n.hardwareConcurrency||0, n.deviceMemory||0, botSignals().webdriver ? "webdriver" : "human"].join("|"); var hash = 0; for (var i=0;i maxScroll) maxScroll = depth; [25,50,75,90,100].forEach(function(threshold){ if (depth >= threshold && !sentScrollThresholds[threshold]) { sentScrollThresholds[threshold] = true; enqueue("scroll_" + threshold, {scroll_threshold:threshold}, {immediate:false}); } }); }, {passive:true}); d.addEventListener("click", function(event){ clickCount++; var target = event.target && event.target.closest ? event.target.closest("a,button,input,select,textarea,[role=button]") : null; var now = Date.now(); recentClicks = recentClicks.filter(function(click){ return now - click.time < 1500; }); recentClicks.push({time:now,x:event.clientX,y:event.clientY}); var clustered = recentClicks.filter(function(click){ return Math.abs(click.x-event.clientX)<24 && Math.abs(click.y-event.clientY)<24; }); if (clustered.length >= 3) { rageClickCount++; enqueue("rage_click", {x:event.clientX,y:event.clientY}, {immediate:true}); } if (!target) { deadClickCount++; return; } var href = target.href || "", host = target.hostname || ""; var eventType = "click"; if (href.indexOf("tel:")===0) { phoneClickCount++; eventType = "phone_click"; } else if (href.indexOf("mailto:")===0) { emailClickCount++; eventType = "email_click"; } else if (/(^|\.)wa\.me$|(^|\.)whatsapp\.com$/i.test(host)) { outboundClickCount++; eventType = "whatsapp_click"; } else if (/(^|\.)t\.me$|(^|\.)telegram\.me$|(^|\.)telegram\.org$/i.test(host)) { outboundClickCount++; eventType = "telegram_click"; } else if (href && host && host !== w.location.hostname) { outboundClickCount++; eventType = "outbound_click"; } enqueue(eventType, {tag:target.tagName, label:(target.innerText || "").replace(/\s+/g," ").slice(0,120), href:href || null, href_domain:host || null}, {immediate:false}); }, true); d.addEventListener("focusin", function(event){ if (event.target && ["INPUT","SELECT","TEXTAREA"].indexOf(event.target.tagName) !== -1) enqueue("form_start", {form_id:(event.target.form && event.target.form.id)||null}, {immediate:false}); }, true); d.addEventListener("submit", function(event){ formSubmitCount++; enqueue("form_submit", {form_id:event.target.id||null, form_name:event.target.name||null}, {immediate:true}); }, true); d.addEventListener("change", function(event){ if (event.target && ["INPUT","SELECT","TEXTAREA"].indexOf(event.target.tagName) !== -1) inputChangeCount++; }, true); d.addEventListener("copy", function(){ copyCount++; enqueue("copy", {}, {immediate:false}); }, true); w.addEventListener("pagehide", function(){ enqueue("session_end", {}, {beacon:true}); }); enqueue(Object.keys(googleAdsParams(allParams())).length ? "ad_landing" : "page_view", {}, {immediate:true}); })(window, document, navigator);