Interstitial ads
Add a way to close the interstitial ad
You can use one of the methods below to close an interstitial ad built for the Display & Video 360 environment.
Auto-close automatically closes the ad after a set period of time, while a close button allows the viewer to close the ad.
Add auto-close
In the example below, the ad auto-collapses after 15 seconds.
-
Add a new event, making these selections in the event dialog:
Target document.body Event Google Ad > Ad initialized Action Custom > Add custom action Configuration Give the function a name, such as closeAfter15s, then enter the following custom code (adjusting the time period as necessary):setTimeout(autoClose, 15000);
function autoClose() {
Enabler.close();
}
Add a close button
-
Create a button or other clear visual element for closing the ad.
-
Add a Tap Area component positioned over the button.
-
Add a new event, making these selections in the event dialog:
Target gwd-taparea-1 (or the ID of the Tap Area component) Event Tap Area > Touch/Click Action Custom > Add custom action Configuration Give the function a name, such as closeAd, then enter the following custom code:Enabler.reportManualClose();
Enabler.close();
Testing in preview
To verify in preview that the ad closes correctly, open the developer console in the browser and look for the "Closing ad" event.
Was this helpful?
How can we improve it?
