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. ados.js fires a number of messages based on ad serving events.

You can add the ados.on(); function to your JavaScript ad code to listen for 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 i.e. 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 message "ImpressionCounted". The message data includes the impression shim, which includes the name of the div and the userkey as the value of the uk field. When the event takes place, the callback logs the divId and userkey for all impressions loaded for the page to the JS console:

user key for azk123456 is: ue-29thd03

If you have any questions about ados.js callbacks, please contact Kevel support.