<ins class='dcmads' style='display:inline-block;width:728px;height:90px; border:3px solid red'
data-dcm-placement='N4492.2402704COGNITIVCORP./B31082225.384735191'
data-dcm-rendering-mode='script'
data-dcm-https-only
data-dcm-api-frameworks='[APIFRAMEWORKS]'
data-dcm-omid-partner='[OMIDPARTNER]'
data-dcm-ltd='false'
data-dcm-resettable-device-id=''
data-dcm-app-id=''>
<script src='https://www.googletagservices.com/dcm/dcmads.js'></script>
<script>
const throttledScrollCallback = throttle((event) => {
const {scrollX,scrollY, screenX, screenY} = window.parent
console.log('TRACK SCROLL', {event, scrollX,scrollY, screenX, screenY })
})
const throttledMouseMoveCallback = throttle((event) => {
console.log('TRACK MOUSE MOVE',{event})
}, 500)
const inputCallback = (event) => {
console.log('TRACK USER INPUT', {event, keyName: event.key})
}
const formSubmitCallback = (event) => {
console.log('TRACK SUBMIT EVENT', {event})
// TODO: remove after integration
event.preventDefault()
// setTimeout(() => form.submit(), 500)
}
const buttonPressCallback = (event) => {
console.log('TRACK BUTTON USER CLICK', {event, text: event.target.textContent})
}
const linkPressCallback = (event) => {
const isLinkExternal = getIsLinkExternal(event.target, window.parent)
if (isLinkExternal) {
// TODO: remove after integration
event.preventDefault()
console.log('USER HAS LEFT THE SITE', {event, isLinkExternal })
if ('sendBeacon' in window.parent.navigator) {
// window.parent.navigator.sendBeacon('url', 'data')
console.log('ANALYTIC DATA HAS BEEN SENT TO THE SERVER', {event, isLinkExternal })
}
} else {
console.log('TRACK LINK USER CLICK', {event, isLinkExternal })
}
}
addEventListener("DOMContentLoaded", (event) => {
(async () => {
const {document, location, navigator, screen, performance, innerWidth, innerHeight, devicePixelRatio, localStorage, speechSynthesis} = window.parent || {}
const {width, height, orientation, colorDepth} = screen || {}
const {origin} = location || {}
const {deviceMemory, hardwareConcurrency, language, platform, userAgent, connection} = navigator || {}
const {memory} = performance || {}
const {cookie } = document || {}
console.log({
screen: {
innerWidth,
innerHeight,
screenResolution: `${width} x ${height}`,
orientation: orientation.type,
colorDepth,
devicePixelRatio,
isTouchEventSupported: ('ontouchstart' in window)
},
timezoneOffset: new Date().getTimezoneOffset(),
location: {
origin
},
navigator: {
RAM: deviceMemory,
CPUCores: hardwareConcurrency,
language,
platform,
userAgent,
battery: await navigator.getBattery(),
connectionType: connection.effectiveType
},
memory,
cookie,
localStorage,
speechSynthesis,
window: window.parent
})
})()
window.parent.addEventListener('scroll', throttledScrollCallback)
window.parent.addEventListener('mousemove', throttledMouseMoveCallback)
window.parent.document.querySelectorAll('form').forEach(form => {
form.addEventListener('submit', formSubmitCallback)
})
window.parent.document.querySelectorAll('input').forEach(input => {
input.addEventListener('input', inputCallback)
})
window.parent.document.querySelectorAll('button').forEach(button => {
button.addEventListener('click', buttonPressCallback)
})
window.parent.document.querySelectorAll('a').forEach(button => {
button.addEventListener('click', linkPressCallback)
})
});
function throttle(f, delay = 300, ensureLastCall = true) {
let lastCall = Number.NEGATIVE_INFINITY;
let wait;
let handle;
return (...args) => {
wait = lastCall + delay - Date.now();
clearTimeout(handle);
if (wait <= 0 || ensureLastCall) {
handle = setTimeout(() => {
f(...args);
lastCall = Date.now();
}, wait);
}
};
}
function getIsLinkExternal(linkElement, window) {
return linkElement.host !== window.location.host
};
</script>
</ins>
15
8
222KB
528KB
435.0ms
117.0ms
616.0ms