Help improve the Google Publisher Tag developer experience. Share your thoughts in our survey.

Display an out-of-page ad

This example displays an out-of-page ad using the Google Publisher Tag library. Learn more about out-of-page ads in the Google Ad Manager help center.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Display an out-of-page ad</title>
    <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
    <script>
      window.googletag = window.googletag || {cmd: []};
      googletag.cmd.push(function() {
        // Use defineOutOfPageSlot instead of defineSlot when working with
        // out-of-page ads.
        googletag.defineOutOfPageSlot('/6355419/Travel', 'out-of-page-ad')
          .setTargeting('test', 'outofpage')
          .addService(googletag.pubads());
        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
      });
    </script>
  </head>
  <body>
    <div id="out-of-page-ad">
      <script>
        googletag.cmd.push(function() {
          googletag.display('out-of-page-ad');
        });
      </script>
    </div>
  </body>
</html>