AI-generated Key Takeaways
-
This document describes the
AdEvent
type, which is triggered when an ad's state changes or when users interact with it, extending from theImaEvent
type. -
The
AdEvent
object includes propertiescurrentTarget
,target
, andtype
, all of which are inherited fromImaEvent
. -
The
getAd
method allows you to retrieve the currently playing or recently played ad, while thegetAdData
method enables the retrieval of additional data passed from the ad. -
preventDefault
andstopPropagation
methods are inherited fromImaEvent
to control the event flow. -
The
getAdData
method is exemplified in a code snippet that checks for log events of typeAdEvent
for error handling.
Properties | |
---|---|
current
|
Deprecated.
Inherited from
|
target
|
The object on which the event was raised (and to which a listener was added).
Inherited from
|
type
|
Inherited from
|
Methods | |
---|---|
get
|
Get the current ad that is playing or just played. |
get
|
Allows extra data to be passed from the ad. |
prevent
|
Deprecated.
Inherited from
|
Properties
Optional
currentTarget
currentTarget?: object
Optional
target
target?: object
type
type: string
Methods
getAd
getAdData
getAdData(): object
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 | |
---|---|
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