Display a web interstitial ad

This example demonstrates how to display a web interstitial ad using the Google Publisher Tag (GPT) library. Web interstitials are GPT-managed, full-page ads that appear in response to user actions. For more information about web interstitials, see Traffic web interstitials.

The following user actions are eligible to trigger a web interstitial ad:

User action API name Default Configurable
Navigating away from the page in response to a click. N/A Enabled No
Clicking on the browser navigation bar. (Desktop only) navBar Disabled Yes
Hiding and then returning to the page (for example, by switching tabs). unhideWindow Disabled Yes

Support for additional user actions may be added in the future. Follow the GPT release notes for updates.

Usage notes

  • To ensure an optimal user experience, GPT only requests web interstitial ads on pages that properly support the format. Web interstitials are only supported when GPT is running in the top window. On pages that don't support web interstitials, defineOutOfPageSlot() may return null. Be sure to check for this to avoid errors.

  • Only request web interstitial ads on pages or environments where you want an interstitial to appear. Web interstitial ads are eligible to serve to desktop, tablet, and mobile devices.

  • Web interstitial ads generate their own ad slot. Unlike other ad types, you don't need to define a <div> for web interstitial ads. These ads automatically create and insert their own container into the page when an ad fills.

  • Web interstitial ads have a fixed frequency cap. This prevents the same user from being shown an interstitial more than once per hour, per subdomain.

  • Web interstitial ads require access to local storage. For publishers integrated with the IAB Transparency and Consent Framework v2.0, this means that consent for Purpose 1 is required for web interstitial ads to function.

  • Some links on a page might be ineligible to show web interstitial ads. Interstitial ads won't show when a user clicks an ineligible link, for example, links to URLs without HTTP/HTTPS, and links that open in a new window.

  • If using single-request architecture (SRA) on a page with multiple slots, don't call display() until static ad slots divs are created. As explained in Ad Best Practices, the first call to display() requests every ad slot defined prior to that point. Although web interstitial slots don't require a predefined <div>, static ad slots do. Calling display() before these elements are present on the page can result in lower quality signals, reducing monetization. Because of this, we recommend delaying the initial call until after the static slots are defined.

Sample implementation

View demo