-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
First of all, thank you for your great module. I couldn't have finished my project without it.
When creating ads on infinite scroll screen, I had to use same ad units in Google Ad Manager.
if (onSlotRenderEnded) {
googletag.cmd.push(() => {
googletag.pubads().addEventListener('slotRenderEnded', (event) => {
// check if the current slot is the one the callback was added to
// (as addEventListener is global)
if (event.slot.getAdUnitPath() === path) {
onSlotRenderEnded(event);
}
});
});
}
Above code only check the path of the ad unit, so I added && statement to validate the slotElementId.
// Execute callback when the slot is visible in DOM (thrown before 'impressionViewable' )
if (onSlotRenderEnded) {
googletag.cmd.push(() => {
googletag.pubads().addEventListener('slotRenderEnded', (event) => {
// check if the current slot is the one the callback was added to
// (as addEventListener is global)
if (event.slot.getAdUnitPath() === path && event.slot.getSlotElementId() === id) {
onSlotRenderEnded(event);
}
});
});
}
Also, when the Ad component unmounts, the event handler do not get removed. So it would be a good idea to remove the event handler in componentWillUnmount.
Metadata
Metadata
Assignees
Labels
No labels