according to the documentation at https://developers.google.com/doubleclick-gpt/reference#googletag.events.SlotRenderEndedEvent
there should be a way to register to an event that a tag was rendered:
Class googletag.events.SlotRenderEndedEvent
This event is fired when a slot on the page has finished rendering.
but when i inspected the dfp object i don't see any event namespace
any idea how to register to this event?
Google Publisher Tag (GPT) is an ad tag library that allows publishers to define inventory, initiate and bundle ad requests, and render matching demand. GPT takes key details from you (such as ad unit code, ad size, and key-values), builds the request, and displays the ad on web pages.
Other options to open the Publisher ConsoleAfter loading the page, enter javascript: googletag. openConsole() in your browser's JavaScript console and run the code. Developer Tools. Click Console.
googletag.Constructs an ad slot with a given ad unit path and size and associates it with the ID of a div element on the page that will contain the ad. Example. googletag. defineSlot('/1234567/sports', [728, 90], 'div-1'); See also.
To register the event, use the following code:
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.defineSlot('/123456/leadeboard', [[728, 90]], 'div-gpt-ad-123456789-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
console.log('Slot has been rendered:');
});
googletag.enableServices();
});
</script>
The documentation is found in the GPT reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With