Interface AdEvent


Extends ImaEvent
This event type is raised by the ad as a notification when the ad state changes and when users interact with the ad. For example, when the ad starts playing, is clicked on, and more. You can register for the various state changed events on AdsManager.
Properties
currentTarget?
target?
type
Methods
getAd
Get the current ad that is playing or just played.
getAdData
Allows extra data to be passed from the ad.
preventDefault
stopPropagation

Properties


Optional currentTarget

currentTarget?: null | object

Optional target

target?: null | object

type

type: string

Methods


getAd

getAd(): null | Ad
Get the current ad that is playing or just played.
Returns
null | Ad The ad associated with the event, or null if there is no relevant ad.

getAdData

getAdData(): null | object
Allows extra data to be passed from the ad.

Example:

  if (event.type == google.ima.AdEvent.Type.LOG) { let adData = event.getAdData(); if (adData['adError']) { console.log('Non-fatal error occurred: ' + adData['adError'].getMessage()); } } 
Returns
null | object Extra data for the event. Log events raised for error carry object of type 'google.ima.AdError' which can be accessed using 'adError' key.

preventDefault

preventDefault(): void

stopPropagation

stopPropagation(): void