Registering Callbacks From the JavaScript Ad Code
Overview
ados.js is the client-side JavaScript library that Kevel's ad code uses to request and display ads in the browser. As ads are served, it fires messages for a range of events.
You can add the ados.on() function to your JavaScript ad code to listen for those events and register callbacks.
Available Events
| Event | Description |
|---|---|
ImpressionCounted | Fired when an impression pixel is loaded to the page |
load | Fired when ados.js is loaded |
log | Fired whenever ados.js logs something to the JS console |
passbackExec | Fired whenever a passback chain renders an ad (note that the ad may include a passback from a 3rd party server, so this may not indicate the final served ad) |
passbackLoad | Fired when a passback chain starts loading |
passbackNext | Fired at each step of the passback chain |
passbackTimeout | Fired when a passback times out |
refresh | Fired whenever the ad code refreshes, meaning whenever ados_refresh is called |
requestStart | Fired when an ad request is made |
Registering Callbacks
The format for using ados.on() is:
ados.on(message, callback);
For example:
ados.on("ImpressionCounted", function(msg) {
console.log("user key for " + msg.data.div + " is: " + msg.data.shim.uk);
});This listens for the ImpressionCounted message. The message data carries the impression shim, which holds the name of the div and the userkey in its uk field. Each time the event fires, the callback logs the div name and userkey to the JS console, for every impression loaded on the page:
user key for azk123456 is: ue-29thd03
If you have any questions about ados.js callbacks, please contact Kevel support.
Updated 8 days ago
