Iframe Events
Advertisers can track events in their ads. These events are programmatically managed directly in the client browser with the help of JavaScript.
Events
creativeDisplayed
When the ad displays, it sends a creativeDisplayed message to the iframe.
Use the following event listener inside the iframe to track this message once the ad is displayed to the user.
<script>
function readMessage(event) {
// Only accept messages from the network's ad-serving domain
if (event.origin !== "https://s.<network-domain>") return;
console.log("readMessage event");
console.log("origin: " + event.origin);
console.log("data: " + event.data);
}
if (window.addEventListener) {
// For standards-compliant web browsers
window.addEventListener("message", readMessage, false);
} else {
window.attachEvent("onmessage", readMessage);
}
</script>Example - Fullpage Interstitial
Last updated
Was this helpful?

