Remove empty ad slot

pull/8372/head
Kamran Ahmed 4 weeks ago
parent f9c2c4153d
commit d388c2c563
  1. 19
      src/components/Analytics/GoogleAd.astro

@ -90,5 +90,24 @@ const page = Astro.url;
}
googletag.enableServices();
googletag.pubads().addEventListener('slotRenderEnded', function (e) {
if (!e.isEmpty) {
return;
}
const slotId = e.slot.getSlotElementId();
if (!slotId) {
return;
}
// If empty, hide the ad slot after a small delay.
setTimeout(() => {
const adContainer = document.getElementById(slotId);
if (adContainer) {
adContainer.style.display = 'none';
}
}, 1800);
});
});
</script>

Loading…
Cancel
Save