A timer lets you measure the length of any action in a creative, for example, the amount of time a user plays a game. There isn't a component for adding a timer to a creative, so you must use the API.
To start a timer:
Call the method:
enabler.startTimer(timerId:String);
To stop a timer:
Call this method:
enabler.stopTimer(timerId:String);
timerIdis your timer's name in Studio. You can rename this in the Studio Web UI or in DFA Trafficking to change what shows up in the final report.- To successfully stop the timer, the
timerIdused instopTimermust match the ID used instartTimer
Try it!
- Add two buttons to your creative, naming one
myStartTimerBtnand the othermyStopTimerBtn. - Make a timer named "My Timer" start when the user clicks the
myStartTimerBtnobject and stop when the user clicks themyStopTimerBtnobject.
AS3 code snippet
var onStartTimerHandler:Function = function(event:MouseEvent):void {
enabler.startTimer("My Timer");
}
var onStopTimerHandler:Function = function(event:MouseEvent):void {
enabler.stopTimer("My Timer");
}
myStartTimerBtn.addEventListener(MouseEvent.CLICK, onStartTimerHandler);
myStopTimerBtn.addEventListener(MouseEvent.CLICK, onStopTimerHandler);
Test your work
Run the creative in Flash. When you click the start and stop timer buttons, the following traces should appear in the output panel :
Enabler: Start timer: My Timer
Enabler: Stop timer: My Timer
