Skip to main content

Standard and Custom Refresh Options

Ad Lightning standard and custom refresh options

J
Written by Jennifer Busca
Updated over 2 weeks ago

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.

Fallback Tag

You can also load a fallback tag to control what's served when the slot is empty. If a fallback tag is implemented and there are three consecutive blocks, the default tag will serve instead of leaving the ad slot blank.

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
}
}
});

Did this answer your question?