App.js Events
Introduction
Asynchronous JavaScript ad serving will now emit events that can be listened to in your JavaScript. The events can be listened to with element.addEventListener. The CustomEvent API is used, so the event data will be found in the CustomEvent.detail property.
Events
Request
This event is emitted when the ad request is first sent. This event will also be emitted for each refresh on refreshing ads.
The event can be listened to with element.addEventListener('adbutlerOnRequest', handler)
.
Property | Type | Description |
---|---|---|
elementID | string | The ID of the DOM element containing the ad |
place | int | The zone's place ID |
refreshNumber | int | The refresh number for the current ad request. The first request will be 0 and subsequent refreshes will be one refresh number higher. This can be used to associate a set of request/response/load/viewable events to a particular refresh of a zone. |
size | string | The dimensions of zone as width x height, ie 300x250 |
zoneID | int | The zone ID of the zone that is requesting an ad. |
Response
This event is emitted when the ad request has returned. This event will also be emitted for each refresh on refreshing ads.
The event can be listened to with element.addEventListener('adbutlerOnResponse', handler)
.
Property | Type | Description |
---|---|---|
elementID | string | The ID of the DOM element containing the ad |
place | int | The zone's place ID |
refreshNumber | int | The refresh number for the current ad request. The first request will be 0 and subsequent refreshes will be one refresh number higher. This can be used to associate a set of request/response/load/viewable events to a particular refresh of a zone. |
size | string | The dimensions of zone as width x height, ie 300x250 |
zoneID | int | The zone ID of the zone that is requesting an ad. |
| filled | boolean | Whether or not the ad response was filled. This will be true when an ad is returned and false when no ad is returned. |
Load
This event is emitted once the ad has loaded. This will include the image load time for an image ad. This event will also be emitted for each refresh on refreshing ads.
The event can be listened to with element.addEventListener('adbutlerOnLoad', handler)
.
Property | Type | Description |
---|---|---|
elementID | string | The ID of the DOM element containing the ad |
place | int | The zone's place ID |
refreshNumber | int | The refresh number for the current ad request. The first request will be 0 and subsequent refreshes will be one refresh number higher. This can be used to associate a set of request/response/load/viewable events to a particular refresh of a zone. |
size | string | The dimensions of zone as width x height, ie 300x250 |
zoneID | int | The zone ID of the zone that is requesting an ad. |
Viewable
This event is emitted once the ad has been registered as viewable. This event will also be emitted for each refresh on refreshing ads.
The event can be listened to with element.addEventListener('adbutlerOnViewable', handler)
.
Property | Type | Description |
---|---|---|
elementID | string | The ID of the DOM element containing the ad |
place | int | The zone's place ID |
refreshNumber | int | The refresh number for the current ad request. The first request will be 0 and subsequent refreshes will be one refresh number higher. This can be used to associate a set of request/response/load/viewable events to a particular refresh of a zone. |
size | string | The dimensions of zone as width x height, ie 300x250 |
zoneID | int | The zone ID of the zone that is requesting an ad. |