我想检查我的广告是否退回。 我的代码看起来像这样
<script>
googletag.cmd.push(function () {
var targetSlot = 'div-gpt-ad-id';
googletag.pubads().addEventListener('impressionViewable', function(event) {
if (event.slot == targetSlot) {
console.log("ad viewable");
}
});
googletag.defineSlot('slot-name', [size], 'div-gpt-ad-id').addService(googletag.pubads());
googletag.defineSlot('slot-name', [size], 'div-gpt-ad-id').addService(googletag.pubads());
googletag.defineSlot('slot-name', [size], 'div-gpt-ad-id').addService(googletag.pubads());
googletag.defineSlot('slot-name', [size], 'div-gpt-ad-id').addService(googletag.pubads());
googletag.defineSlot('slot-name', [size], 'div-gpt-ad-id').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
事件监听器对我不起作用。 我尝试了所有这些方法,但没有一个对我有用:
// 1. Slot render ended listener.
// The listener will be called only when the pubads service renders a slot.
// To listen to companion ads, add a similar listener to
// googletag.companionAds().
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
console.log('Slot has been rendered:');
console.log(event);
});
// 2. Slot render ended listener, slot specific logic.
// Listeners operate at service level, which means that you cannot add a
// listener for a slotRenderEnded event for a specific slot only. You can,
// however, programmatically filter a listener to respond only to a certain
// ad slot, using this pattern:
var targetSlot = ...;
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
if (event.slot === targetSlot) {
// Slot specific logic.
}
});
// 3. Impression viewable listener, slot specific logic.
// The listener will be called when the impression is considered viewable.
// This event also operates at service level, but, as above, you can filter
// to respond only to a certain ad slot by using this pattern:
googletag.pubads().addEventListener('impressionViewable', function(event) {
if (event.slot == targetSlot) {
// Slot specific logic.
}
});
有人知道如何检查展示位置是否已满或返回空吗?