registering to events with google publisher tag

霸气de小男生 提交于 2020-01-14 07:54:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/24792393/registering-to-events-with-google-publisher-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!