Events
The SDK notifies the app about every step of playback. Event names are the same on all platforms; only the delivery method differs: Android, iOS, browser.
Event order is described under Ad lifecycle.
Event list
| Event | When it arrives | Data |
|---|---|---|
AdTagStartLoading | VAST tag loading started | — |
AdTagLoaded | VAST tag loaded | ad_is_no_banner |
AdLoaded | Creative loaded and ready to play | see below |
AdStarted | Ad playback started (once per pod) | ad_number |
AdCreativeStarted | An ad started playing (for each ad in the pod) | ad_number |
AdFirstQuartile | 25% of the ad watched | ad_number |
AdMidpoint | 50% of the ad watched | ad_number |
AdThirdQuartile | 75% of the ad watched | ad_number |
AdComplete | Ad watched to the end | ad_number, ad_is_last, ad_is_pod |
AdPaused | Playback paused | — |
AdResumed | Playback resumed | — |
AdSkippableStateChanged | The ad became skippable | status |
AdSkipped | The ad was skipped | ad_number |
AdClick | Click-through on the ad | url, ad_number |
AdClosed | The user closed the creative | — |
AdDisable | The "disable ads" button was pressed | — |
AdSetURL | The video file for playback was selected | ad_media_file_url |
AdError | Loading or playback error | see below |
AdDestroyed | Ad playback finished, resources released | ad_is_last |
AdPodCompleted | The whole ad pod finished showing | ad_pod_length, ad_pod_showed_count, ad_is_last |
AdsEnded | All ad playback finished (browser only) | — |
Fields
| Field | Type | Description |
|---|---|---|
ad_number | number | The ad's position in the pod, starting at 1. -1 for a single-ad response. |
ad_is_last | boolean | The ad is the last one in the pod. |
ad_is_pod | boolean | The ad is a pod of multiple ads. |
ad_is_no_banner | boolean | The response contains no ad. |
status | boolean | Whether the ad can be skipped. The SDK sends the event with true when the ad becomes skippable. |
url | string | Click-through link to the advertiser's site. |
ad_media_file_url | string | URL of the selected video file. |
ad_pod_length | number | Number of creatives in the pod. |
ad_pod_showed_count | number | How many creatives of the pod were shown. |
AdLoaded
| Field | Type | Description |
|---|---|---|
ad_creative_src_url | string | Creative URL. |
ad_creative_banner_id | string | Banner ID. |
ad_creative_type | string | Creative type. |
ad_creative_duration_sec | number | Duration in seconds. |
ad_creative_duration_msec | number | Duration in milliseconds. |
ad_media_file_src_url | string | Video file URL. |
ad_number | number | The ad's position in the pod. |
ad_is_no_banner | boolean | The response contains no ad. |
ad_is_pod | boolean | The ad is a pod of multiple ads. |
ad_is_last | boolean | The ad is the last one in the pod. |
ad_pod_length | number | Number of ads in the pod. |
erid | string | The creative's ERID, or an empty string. |
AdError
| Field | Type | Description |
|---|---|---|
code | string | Error code, see Errors. |
message | string | Error description. |
type | string | adLoadError — loading error, adShowError — playback error. |
ad_is_no_banner | boolean | The response contains no ad. |
ad_is_last | boolean | The ad is the last one in the pod. |
ad_number | number | The ad's position in the pod. |
Android
The SDK calls methods on the window.Android JavaScript interface. Arguments are passed positionally. Declare methods with exactly the number of arguments shown in the table.
| Event | Call |
|---|---|
AdTagStartLoading | AdTagStartLoading() |
AdTagLoaded | AdTagLoaded(), then AdCreativeVastLoaded(ad_is_no_banner) |
AdLoaded | AdCreativeLoaded(ad_creative_src_url, ad_creative_type, ad_creative_banner_id, ad_is_no_banner, ad_is_pod, ad_pod_length, ad_is_last, erid, ad_creative_duration_msec), then AdLoaded(ad_media_file_src_url) |
AdStarted | AdStarted(ad_number) |
AdCreativeStarted | AdCreativeStarted(ad_number) |
AdFirstQuartile | AdFirstQuartile(ad_number) |
AdMidpoint | AdMidpoint(ad_number) |
AdThirdQuartile | AdThirdQuartile(ad_number) |
AdComplete | AdComplete(ad_number) |
AdPaused | AdPaused() |
AdResumed | AdResumed() |
AdSkippableStateChanged | AdSkippableStateChanged(status) |
AdSkipped | AdSkipped(ad_number) |
AdClick | AdClick(url, ad_number) |
AdClosed | AdClosed() |
AdDisable | AdDisable() |
AdSetURL | AdSetURL(ad_media_file_url) |
AdError | AdError(code, message, type, ad_is_no_banner, ad_is_last, ad_number) |
AdDestroyed | AdDestroyed(ad_is_last) |
AdPodCompleted | AdPodCompleted(ad_is_last) |
AdError arrives once, including when the error happens before the ad loads (for example, the page address has no url). The SDK calls the six-argument method. If the app declared only the legacy AdError(code, message, type, ad_is_no_banner) or AdError(code, message, type) signature, the SDK calls that one instead.
iOS
The SDK sends messages to the AdEventsHandler handler:
window.webkit.messageHandlers.AdEventsHandler.postMessage({ name: 'AdLoaded', ...data });The name field holds the event name; the remaining fields are the event data from the list.
{
"name": "AdComplete",
"ad_number": 1,
"ad_is_last": true,
"ad_is_pod": false
}Browser
Subscribe via loader.on(). The handler receives an object with data from the list.
loader.on('AdClick', ({ url, ad_number }) => {
window.open(url, '_blank');
});