(function(){!function(e,n,s){function o(e,n){return typeof e===n}function a(){var e,n,s,a,t,f,l;for(var c in r)if(r.hasOwnProperty(c)){if(e=[],n=r[c],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(s=0;s (ev) => { d.addEventListener(ev, handler) } documentHandlers.forEach(listener(document)); windowHandlers.forEach(listener(window)); document.addEventListener('DOMContentLoaded', function(){ document.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { linkClickHandler(link) }); }); document.querySelectorAll('form').forEach(form => { form.addEventListener('submit', () => { formSubHandler(form) }); }); }); return { trackingInit: function (apiUrl) { this.migrate(); const data ={ sessionId: this.getSessionId(), eventId: this.getEventId(), cust_sess: this.attemptGetCookie(hidKey), dataLayer: this.attempteGetDataLayer(), clientId: this.getClientId() } return data; }, easyPromise: function (d) { return new Promise((resolve, reject) => { try { resolve(d); } catch (err) { reject({ msg: 'failed to initiate' }); } }); }, loadClientScript: function(url, fn) { JcorsLoader.load(`${url}${fn}`); }, migrate:function(){ const localStorageAlias = window.localStorage; localStorageAlias.removeItem('sc_t'); localStorageAlias.removeItem('sc_fp'); localStorageAlias.removeItem('sc_fp.expires'); const sess = this.attemptGetLocalStorage('sc_sess'); const sessXp = this.attemptGetLocalStorage('sc_sess.expires'); if(sess && sessXp) { this.attemptWriteLocalStorage(sessKey, sess, null); this.attemptWriteLocalStorage(sessKey+'.expires', sessXp, null); } localStorageAlias.removeItem('sc_sess') localStorageAlias.removeItem('sc_sess.expires'); }, getClientId: function() { let clientId = this.attemptGetLocalStorage(uidKey); if(!clientId) { clientId = this.uuidv4() } this.attemptWriteLocalStorage(uidKey, clientId, null); return clientId; }, getVisitorId: function(){ return this.attemptGetLocalStorage(vidKey) }, getEventId: function() { return this.uuidv4(); }, getSessionId: function () { let sessionId = this.attemptGetLocalStorage(sessKey); if (!sessionId) { sessionId = this.uuidv4(); } this.attemptWriteLocalStorage(sessKey, sessionId, 1800); return sessionId; }, setCookie: function() {}, attemptGetCookie: function(key) { try { const val = document.cookie.match('(^|;)\\s*' + key + '\\s*=\\s*([^;]+)')?.pop(); return val; } catch (e) { return undefined; } }, attemptGetLocalStorage: function(key) { try { const localStorageAlias = window.localStorage, exp = localStorageAlias.getItem(key + '.expires'); if (exp === null || exp > Date.now()) { const val = localStorageAlias.getItem(key); if(val === null) { return undefined; } return val; } else { localStorageAlias.removeItem(key); localStorageAlias.removeItem(key + '.expires'); } return undefined; } catch (e) { return undefined; } }, attemptWriteLocalStorage: function(key, value, ttl=63072000) { try { const localStorageAlias = window.localStorage; if (ttl !== null) { const t = Date.now() + ttl * 1000; localStorageAlias.setItem(`${key}.expires`, t.toString()); } localStorageAlias.setItem(key, value); return true; } catch (e) { return false; } }, attempteGetDataLayer: function() { try{ if(dataLayer){ const d = {...dataLayer}; delete d['push']; return JSON.stringify(d); } } catch (err) {} return undefined; }, timeActive: function(lastHeartbeat) { return Math.max(0, (lastActivityTime - lastHeartbeat)/1000) }, scrollDepth: function() { return maxScrollPct; }, recordActivity: function() { activityHandler(); }, pagePingkey: function () { return "pagepings"; }, loadPings: function () { const pings = this.attemptGetLocalStorage(this.pagePingkey()); return pings ? JSON.parse(pings) : {}; }, savePings: function (pings) { this.attemptWriteLocalStorage(this.pagePingkey(), JSON.stringify(pings), null); }, setClientId: function(data) { const r = JSON.parse(data); if(r.success === 200 && r.data && r.data.hid) { const hC = this.attemptGetLocalStorage(uidKey); if(hC === undefined) { this.attemptWriteLocalStorage(uidKey, r.data.hid, null) } this.attemptWriteLocalStorage(vidKey, r.data.hid, null) } }, postData: function(url, payload, helper){ const xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if(xhttp.readyState === 4 && xhttp.status === 200) { helper.setClientId(xhttp.responseText) } } xhttp.open('POST', url); xhttp.setRequestHeader('Content-Type', 'application/json'); xhttp.send(JSON.stringify(payload)); }, uuidv4: function(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))} } } window.sc = (function(){ const ppEnabled = true; const did = "62e12d5a1e81183127518f0b"; const apiUrl = "https://" + "cdn.hedingham.ai" + "/"; const helpers = p_helpers() const payloadVars = helpers.trackingInit(apiUrl); return ( setTimeout(function (){ window.sc.pageview(); }), { pixel: function(payload) { payload.c = payloadVars.clientId; payload.v = payloadVars.clientId; payload.sess = payloadVars.sessionId; payload.ev = payload.ev || payloadVars.eventId; payload.did = did; payload.cust_sess = payloadVars.cust_sess; payload.t = new Date().toISOString(); payload.tz = Intl.DateTimeFormat().resolvedOptions().timeZone; payload._v = '2.0.0'; payload.dl = payloadVars.dataLayer; helpers.postData(apiUrl, payload, helpers); }, event: function(n, data) { const payload = { n: n, u: location.href, data: JSON.stringify(data) } this.pixel(payload); helpers.recordActivity(); }, formsumbit: function (formName, formData) { const payload = { n: 'formsubmit', u: location.href, d: window.location.host, fn: formName, fd: JSON.stringify(formData) } this.pixel(payload); }, linkclick: function (linkUrl) { const payload = { n: 'linkclick', u: location.href, d: window.location.host, lu: linkUrl } this.pixel(payload); }, pageview: function () { const payload = { n: 'pageview', u: location.href, d: window.location.host, r: document.referrer || "", w: window.innerWidth, h: window.innerHeight, dw: screen.width, dh: screen.height, charset: document.characterSet, title: document.title }; this.pixel(payload); }, pageping: function() { const payloads = []; const pings = helpers.loadPings(); for (id in pings) { if (pings[id].sendPing) { payloads.push({ n: 'pageping', u: location.href, ev: id, pt: pings[id].pt, sd: pings[id].sd }); pings[id].sendPing=false; } if (id !== payloadVars.eventId) { delete pings[id]; } } helpers.savePings(pings); for (let i = 0; i < payloads.length; i++) { this.pixel(payloads[i]); } }, activetime: function(lastHeartbeat) { const activeSeconds = helpers.timeActive(lastHeartbeat); const pings = helpers.loadPings(); let ogVal = 0; if (!pings[payloadVars.eventId]) { pings[payloadVars.eventId] = {pt:0, sd:0, sendPing: false} } pings[payloadVars.eventId].pt += activeSeconds; pings[payloadVars.eventId].sd = helpers.scrollDepth(); pings[payloadVars.eventId].sendPing = pings[payloadVars.eventId].sendPing || activeSeconds > 0; helpers.savePings(pings) }, fpb: function() { const fp = helpers.attemptGetLocalStorage(fpKey); if(!fp) { helpers.loadClientScript(apiUrl, 'index.js/'); } }, fpc: function(fp) { helpers.attemptWriteLocalStorage(fpKey, 1, 21600); this.pixel({n: 'fp', fpc:fp}); }, botDetect: function(){ const bot = helpers.attemptGetLocalStorage(isBotKey); if(!bot) { helpers.loadClientScript(apiUrl, 'dtob.js/'); } }, bd: function(p) { helpers.attemptWriteLocalStorage(isBotKey, p.bot, null); p.n='bd'; this.pixel(p); } } ); })(); (function() { let lastHeartbeat = Date.now(); setInterval(function(){ let nextHeartbeat = Date.now(); window.sc.activetime(lastHeartbeat); lastHeartbeat = nextHeartbeat; }, 5000) })(); (function() { window.sc.pageping(); setInterval(function(){ window.sc.pageping(); }, 30000) })(); (function() { setTimeout(function() { window.sc.fpb(); },2500); })(); (function () { setTimeout(function () { window.sc.botDetect(); }, 2500); })();