Ad Lightning Standard Refresh
The Ad Lightning standard refresh works by issuing a GPT refresh. We will block and refresh up to 2x to avoid an endless refresh loop. After that, we'll wait for the page refresh to occur before blocking and refreshing again.
Custom Refresh
We offer option for clients to handle their own refreshes. After a block, we will post the message "ADL_BLOCKED" indicating that we have blocked. Clients can implement an event listener to check for this message. Attached are samples of code that can be used for OP and Creative Wrapper clients.
Please note that we'll also need to make an adjustment on our end to disable our standard refresh, so let us know when you're ready to make the switch and we can make the update.
On Page Script Sample Event Listener
window.addEventListener('message', function (event) {
var data = event.data || {};
console.log('message-event:', event);
console.log('message-data:', data);
if (data.message === 'ADL_BLOCKED') { // only for ADL_BLOCKED message
console.log("AdUnit: ", data.adUnit);
console.log("Adserver Details: ", data.adServerDetails)
if (data.adUnit) { // refresh the blocked ad
var targetSlot = googletag.pubads().getSlots().find(
function (slot) {
return slot.getAdUnitPath() === data.adUnit || slot.getSlotId().getId() === data.adUnit;
}
);
targetSlot && window.setTimeout(function () {
console.log('refreshing:', targetSlot);
googletag.pubads().refresh([targetSlot]);
}, 10);
}
}
});
Creative Wrapper Sample Event Listener
window.addEventListener('message', function (event) {
var data = event.data || {};
console.log('message-event:', event);
console.log('message-data:', data);
if (data.message === 'ADL_BLOCKED') { // only for ADL_BLOCKED message
if (data.adUnit) { // refresh the blocked ad
// TODO: refresh code
}
}
});