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:
| Name | Type | Description |
|---|---|---|
|
|
Received when the state of the plugin is changed. | |
|
|
Received before the ad is added to the list of scheduled ads. You
can cancel the action by returning | |
|
|
Received when the ad is added to the list of scheduled ads. | |
|
|
Received before the ad request is sent to the DFP system. You can
cancel the action by returning | |
|
|
Received when the ad request is sent to the DFP system. | |
|
|
Received when the ad request has been loaded. | |
|
|
Received when the ad is prefetched and ready to start. | |
|
|
Received before the ad starts. You can cancel the action by
returning | |
|
|
Received when the ad starts. | |
|
|
Received when the first quartile is reached. | |
|
|
Received when the mid point is reached. | |
|
|
Received when the third quartile is reached. | |
|
|
Received when the ad finishes. | |
|
|
Received when the ad is clicked. | |
|
|
Received when the ad is paused. | |
|
|
Received when the ad is resumed. | |
|
|
Received when the ad is muted. | |
|
|
Received when the ad size is changed, either when the is player going fullscreen or when the overlay is expanded. | |
|
|
Received when the ad is unloading. | |
|
|
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")
}
}
});
StateChangedEvent
Register an event listener on onStateChanged to receive information when the
state of an ad changes.
| Name | Type | Description |
|---|---|---|
|
|
integer |
The state code of the plugin. Possible values are:
|
|
|
string |
Returns the description of the current state: IDLE, AD_SCHEDULED, … |
|
|
object |
This is the DFP request object. |
|
|
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.
| Name | Type | Description |
|---|---|---|
|
|
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
| Name | Type | Description |
|---|---|---|
|
|
object |
The DFP request object. |
|
|
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.
| Name | Type | Description |
|---|---|---|
|
|
object |
The DFP request object. |
|
|
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). |
|
|
string |
The error type. |
|
|
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:
| Name | Description |
|---|---|
|
|
The ad's internal ID. |
|
|
The survey URL. |
|
|
The traffickingParameters you might have passed in the request. |
|
|
The ad internal ID. |
|
|
The ad type. Possible values are |
You can obtain more info about those fields here.
For video ads, the following fields will be available:
| Name | Description |
|---|---|
|
|
The ad ISCI. |
|
|
The ad author. |
|
|
The delivery type. Usually |
|
|
The media url of the ad. |
|
|
The ad title. |
You can obtain more info about those fields here.
For overlay ads, the following fields will be available:
| Name | Description |
|---|---|
|
|
The height of the ad when expanded. |
|
|
The width of the ad when expanded. |
|
|
The frame rate of the ad. |
|
|
The height of the ad. |
|
|
The width of the ad. |
|
|
The x position of the ad. |
|
|
The y position of the ad. |
You can obtain more info about those fields here.