DFP post-rendering callback

google-dfp, javascript

Solution

The GPT API now has a callback that is triggered after each slot is filled.

For example:

googletag.pubads().addEventListener('slotRenderEnded', function(event) {
 console.log('Creative with id: ' + event.creativeId +
  ' is rendered to slot of size: ' + event.size[0] + 'x' + event.size[1]);
});

See https://developers.google.com/doubleclick-gpt/reference#googletag.events.SlotRenderEndedEvent

Problem

I need to trigger some JavaScript after DFP has finished rendering all the ads on the page - or at least when it has triggered collapseEmptyDivs (which hides ad units that contain no line items). Is anyone aware of a way to get DFP to trigger a callback after either of these events?

Original source

Related problems