What is auto-close?
Auto-close automatically closes a Floating creative after a set period of time.
In addition to a manual close button, publishers often require floaters to auto-close after a set time. This prevents the ad from blocking their site content for too long, especially if there's no user interaction with the ad.
Publishers' site specs always determine whether you add an auto-close. However, DoubleClick recommends that Floating creatives auto-collapse after 15 seconds.
For more information, see Developer best practices.
How do I set up auto-close?
There are two ways to set up auto-close in DoubleClick Rich Media creatives: use the DoubleClick Studio Web UI or the API. We recommend that you use only one of these options.
If you simply want to add auto-close functionality to your creative, we recommend Option 1.
If you want more control over how and when your creative collapses, we recommend Option 2. For example, if you want your creative to stay open if a user is interacting with it, you must use the API to control the auto-close.
Option 1: Use the DoubleClick Studio Web UI
- Setting up auto-close in the Studio Web UI lets you specify a time limit for how long your creative stays open on a page. After the set time, the creative collapses, even if a user is engaging with it.
- If you decide to use the Studio Web UI to auto-close your creative, set it up when you upload your creatives to Studio. Continue to the next step in this build guide for now, and you'll activate auto-close in Floating creative properties, in the Close time section.
- To set up auto-close, call the
enabler.close();method at the end of your timer countdown function. Unlike the close button, you don't have to callenabler.reportManualClose();with this function because this close shouldn't be tracked as a manual close in your reports. - Alternatively, you can call
enabler.close();at the end of a timeline animation of 15 seconds. - Another benefit of the Studio API is that you can set up a Floating creative to stay open if a user is interacting with it. Use the
StudioEvent.INTERACTIONStudio event to do this. This code snippet shows you how:
AS3 code snippet
import com.google.ads.studio.events.StudioEvent;
import flash.utils.Timer;
// Create a timer and auto-close after 15 seconds
var timer:Timer = new Timer(15000,1);
timer.start();
var timerCompleteHandler:Function = function(event:TimerEvent):void {
enabler.close();
}
// Create a function to stop auto-close on user interaction
var onInteractionHandler:Function = function(event:StudioEvent):void {
timer.stop();
}
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
enabler.addEventListener(StudioEvent.INTERACTION, onInteractionHandler);
Try it!
Add an auto-close to your creative using the API.
