Copy the code below and paste it into the Footer field of your plugin. Before saving, replace 23331201958 with your actual Google Ad Manager Network Code.
đ
Where to find your Network Code: Log in to Google Ad Manager â Click the settings gear â Admin â Network Settings. Your network code is shown at the top (a numeric ID like 21700000000).
<!--rewarded -->
<style>
.modal .btn {
padding: .5rem;
background: #2990ea;
border: none;
border-radius: 4px;
margin: 4px;
display: none;
}
.modal p { text-align: center; }
</style>
<script>
googletag = window.googletag || { cmd: [] };
googletag.cmd.push(() => {
const e = localStorage.getItem("hasShownRewardedAd"),
o = Date.now();
if (!e || o - parseInt(e, 10) > 6e5) {
const adSlotRewarded = googletag
.defineOutOfPageSlot(
"/23331201958/video", // â Replace with your network code
googletag.enums.OutOfPageFormat.REWARDED
)
.addService(googletag.pubads());
adSlotRewarded.setForceSafeFrame(true);
googletag.pubads().enableAsyncRendering();
googletag.enableServices();
(function () {
const modal = document.getElementById("rewardModal");
const closeButton = document.querySelector('.modal .btn');
window.addEventListener("popstate", function () {
history.pushState(null, null, location.href);
});
googletag.pubads().addEventListener("impressionViewable", function () {
setTimeout(() => {
closeButton.style.display = "block";
}, 30000); // 30 seconds delay
});
googletag.pubads().addEventListener("slotRenderEnded", function (event) {
if (event.isEmpty) {
setTimeout(function () {
modal.classList.remove("block");
modal.classList.add("hidden");
}, 0);
}
});
googletag.pubads().addEventListener("rewardedSlotReady", function (event) {
modal.classList.remove("hidden");
modal.classList.add("block");
event.makeRewardedVisible();
});
googletag.pubads().addEventListener("rewardedSlotClosed", function () {
modal.classList.remove("block");
modal.classList.add("hidden");
localStorage.setItem("hasShownRewardedAd", o.toString());
});
googletag.display(adSlotRewarded);
})();
}
});
</script>
<div id="rewardModal" class="hidden modal fixed z-10 pt-80 left-0 top-0 w-full h-full overflow-auto bg-black bg-opacity-5">
<div class="modal-content m-auto p-6 bg-slate-100 text-center fixed top-2/4 left-2/4 transform -translate-x-2/4 -translate-y-2/4">
<p>Watch the ad to continue.</p>
<button class="btn">Close Ad</button>
</div>
</div>
<!--rewarded end -->
â
Done! Save the plugin settings. The rewarded video ad will now automatically show to visitors every 10 minutes, significantly boosting your AdX eCPM earnings.