Display a web interstitial ad
Display a GPT-managed web interstitial ad. author(s): Google Publisher Tag Team
by hellosze
HTML
<!doctype html>
<!--
Copyright 2020 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Web Interstitial Ad Example</title>
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
// GPT ad slots
var interstitialSlot, staticSlot;
googletag.cmd.push(function() {
// Define a web interstitial ad slot.
interstitialSlot = googletag.defineOutOfPageSlot(
'/1083753',
googletag.enums.OutOfPageFormat.INTERSTITIAL);
// Slot returns null if the page or device does not support interstitials.
if (interstitialSlot) {
interstitialSlot.addService(googletag.pubads()).setTargeting("partner","undertone_interstitial");
document.getElementById('status').innerText = 'Interstitial is loading...';
// Add event listener to enable navigation once the interstitial loads.
// If this event doesn't fire, try clearing local storage and refreshing
// the page.
googletag.pubads().addEventListener('slotOnload', function(event) {
if (interstitialSlot === event.slot) {
document.getElementById('link').style.display = 'block';
document.getElementById('status').innerText = 'Interstitial is loaded.';
}
...
CSS
body {
min-height: 300px;
}