This is a message.

Events

The Doubleclick DFP plugin allows you to register on low level Javascript events. This is often required when implementing a custom ad logic or your own tracking system. With these low level events, you can monitor the plugin state, get additional ad data, and even cancel actions within the plugin.

In this section:

Registering your listeners

You register your listeners as you would register an onLoad or onBegin listener on the player. Each listener takes an event object as unique parameter, some of which can cancel the associated action.

There are multiple events on which you can register an event listener:

NameTypeDescription

onStateChanged

StateChangedEvent

Received when the state of the plugin is changed.

onBeforeAdScheduled

AdLoaderEvent

Received before the ad is added to the list of scheduled ads. You can cancel the action by returning false.

onAdScheduled

AdLoaderEvent

Received when the ad is added to the list of scheduled ads.

onBeforeAdLoad

AdLoaderEvent

Received before the ad request is sent to the DFP system. You can cancel the action by returning false, and the plugin returns to the IDLE state.

onAdLoad

AdLoaderEvent

Received when the ad request is sent to the DFP system.

onAdLoaded

AdEvent

Received when the ad request has been loaded.

onAdReady

AdEvent

Received when the ad is prefetched and ready to start.

onBeforeAdStart

AdEvent

Received before the ad starts. You can cancel the action by returning false, and the plugin returns to the IDLE state.

onAdStart

AdEvent

Received when the ad starts.

onFirstQuartile

AdEvent

Received when the first quartile is reached.

onMidpoint

AdEvent

Received when the mid point is reached.

onThirdQuartile

AdEvent

Received when the third quartile is reached.

onAdFinished

AdEvent

Received when the ad finishes.

onAdClicked

AdEvent

Received when the ad is clicked.

onAdPaused

AdEvent

Received when the ad is paused.

onAdResumed

AdEvent

Received when the ad is resumed.

onAdMuted

AdEvent

Received when the ad is muted.

onAdSizeChanged

AdEvent

Received when the ad size is changed, either when the is player going fullscreen or when the overlay is expanded.

onAdUnload

AdLoaderEvent

Received when the ad is unloading.

onAdUnloaded

AdLoaderEvent

Received when the ad is unloaded.

function createEventLogger(type) {
return function() {
console.error("Got event "+ type, arguments);
}
}
 
flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
clip: {
autoPlay: false,
url: "http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv",
ads: [{ // our ad is always scheduled
time: 0,
request: {
adTagUrl: "http://ad.doubleclick.net/pfadx/AngelaSite;foo=prodtest;"
+ "sz=728x90;dcmt=text/html"
}
}]
},
 
plugins: {
controls: {
autoHide: "never" // we don't want the controlbar to hide
},
 
dfp: {
url: "flowplayer.dfp-test-1.5.swf",
 
// log some events
onStateChanged: createEventLogger("onStateChanged"),
onAdScheduled: createEventLogger("onAdScheduled"),
onAdLoaded: createEventLogger("onAdLoaded"),
onAdReady: createEventLogger("onAdReady"),
onAdError: createEventLogger("onAdError"),
onAdUnloaded: createEventLogger("onAdUnloaded")
}
}
});

JavaScript

StateChangedEvent

Register an event listener on onStateChanged to receive information when the state of an ad changes.

NameTypeDescription

code

integer

The state code of the plugin. Possible values are:

  • -1, IDLE: Nothing is going on
  • 0, AD_SCHEDULED: An ad is scheduled. The loader will load the ad when needed
  • 1, AD_LOADING: The request has been sent to the DFP system
  • 2, AD_LOADED: The request has been completed. The loader will prefetch the ad when needed.
  • 3, AD_BUFFERING: The asset is being prefetched.
  • 4, AD_READY: The asset is loaded. Waiting the right time to display the ad.
  • 5, AD_PLAYING: The ad is displayed.
  • 6, AD_FINISHED: The ad is unloading. Goes back to IDLE when done.
  • 7, AD_UNLOADING: The ad is unloading. Goes back to IDLE when done.

description

string

Returns the description of the current state: IDLE, AD_SCHEDULED, …

request

object

This is the DFP request object.

ad

object

This is the ad object. You can see its details here. This property can be null is not applicable (when ad is not yet loaded).


AdLoaderEvent

Register an event listener on onBeforeAdScheduled, onAdScheduled, onBeforeAdLoad, onAdLoad, onAdUnload, onAdUnloaded to be signaled when the corresponding ad schedule or load takes place.

NameTypeDescription

request

object

This is the DFP request object.


AdEvent

You get this event by registering:

onAdLoaded, onAdReady, onAdClicked, onBeforeAdStart, onAdStart, onFirstQuartile, onMidpoint, onThirdQuartile, onAdFinished, onAdPaused, onAdResumed, onAdMuted, onAdSizeChanged

NameTypeDescription

request

object

The DFP request object.

ad

object

The ad object. View details on the object here. This property can be null if not applicable (typically when the ad is not yet loaded).


AdErrorEvent

To receive the AdErrorEvent event, register a listener on onAdError.

NameTypeDescription

request

object

The DFP request object.

ad

object

The ad object. View details on the object here. This property can be null is not applicable (typically when the ad is not yet loaded).

errorType

string

The error type.

errorMessage

string

The error message.


The Ad object

The ad object represents the ad that will be displayed. You can use the data from the ad object for your own tracking system. All ad objects contain at least the following fields:

NameDescription

id

The ad's internal ID.

surveyUrl

The survey URL.

traffickingParameters

The traffickingParameters you might have passed in the request.

id

The ad internal ID.

type

The ad type. Possible values are video and flash.

You can obtain more info about those fields here.

For video ads, the following fields will be available:

NameDescription

ISCI

The ad ISCI.

author

The ad author.

deliveryType

The delivery type. Usually progressive.

mediaUrl

The media url of the ad.

title

The ad title.

You can obtain more info about those fields here.

For overlay ads, the following fields will be available:

NameDescription

expandedHeight

The height of the ad when expanded.

expandedWidth

The width of the ad when expanded.

frameRate

The frame rate of the ad.

height

The height of the ad.

width

The width of the ad.

x

The x position of the ad.

y

The y position of the ad.

You can obtain more info about those fields here.