Single VAST tag example:

advertising: {
adBreaks: [{
tag: {
url: 'http://your.ad.provider/vast-manifest.xml',
type: 'vast'
}
}],
}

This is the most simple config example to play a single pre-roll ad.

Single VMAP tag example:

advertising: {
adBreaks: [{
tag: {
url: 'http://your.ad.provider/vmap-manifest.xml',
type: 'vmap'
}
}]
}

This config example will immediately download the VMAP manifest and schedule the resulting ad break(s) based on information in the manifest.

This example plays all the ad breaks in the VMAP manifest based on timing information in the manifest itself, while the three VAST ads are played as a pre-roll, mid-roll at 8 minutes and 30 seconds and a post-roll ad. Additionally, the strategy chosen here will result in every seeked-over ad break being played. The latter two manifests are loaded 5 seconds in advance.

Mixed example:

advertising: {
adBreaks: [{
tag: {
url: 'http://your.ad.provider/vmap-manifest.xml',
type: 'vmap'
},
}, {
tag: {
url: 'http://your.ad.provider/vast-manifest.xml',
type: 'vast'
},
replaceContentDuration: 5,
persistent: true,
id: 'pre-roll-1',
position: 'pre',
}, {
tag: {
url: 'http://your.ad.provider/vast-manifest.xml',
type: 'vast'
},
id: 'mid-roll-1',
position: '00:08:30.000',
preloadOffset: 5
}, {
tag: {
url: 'http://your.ad.provider/vast-manifest.xml',
type: 'vast'
},
persistent: true,
id: 'post-roll-1',
position: 'post',
preloadOffset: 5
}],
strategy: {
shouldPlayAdBreak: (adBreak) => true,
shouldPlaySkippedAdBreaks: (skipped, from, to) => skipped,
}
}
interface ImaAdvertisingConfig {
    adBreaks?: AdConfig[];
    adContainer?: (() => HTMLElement);
    allowedUiElements?: string[];
    beforeInitialization?: ((sdkSettings) => void);
    companionAdContainers?: (() => HTMLElement[]);
    disableStorageApi?: boolean;
    onAdContainerAvailable?: ((adContainer) => void);
    onAdsManagerAvailable?: ((adsManager) => void);
    placeholders?: AdTagPlaceholders;
    sdkUrl?: string;
    strategy?: RestrictStrategy;
    trackers?: Trackers;
    videoLoadTimeout?: number;
    withCredentials?: boolean;
}

Hierarchy (view full)

Properties

adBreaks?: AdConfig[]

Defines a collection of ad breaks which will be played at the specified position in each AdBreakConfig.

adContainer?: (() => HTMLElement)

Defines a function which returns a container that is used for displaying ads.

Type declaration

    • (): HTMLElement
    • Returns HTMLElement

allowedUiElements?: string[]

Defines an array of UI elements that should be displayed when an ad is active. Customizable UI elements are defined at https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima#.UiElements.

Setting this property to an empty array will not show the UI elements mentioned in the link above.

beforeInitialization?: ((sdkSettings) => void)

Callback that provides access to the google.ima.ImaSdkSettings before any initialization happens.

Type declaration

    • (sdkSettings): void
    • Parameters

      • sdkSettings: any

      Returns void

companionAdContainers?: (() => HTMLElement[])

Defines a function which returns an array of containers for the ad module to fill with companion ads.

Type declaration

    • (): HTMLElement[]
    • Returns HTMLElement[]

disableStorageApi?: boolean

When set to true, the ad module will be prohibited from using the browser's localStorage.

Defaults to disableStorageApi, if present, and falls back to false.

Since

v8.91.0

onAdContainerAvailable?: ((adContainer) => void)

Callback that provides access to the ad container.

Type declaration

    • (adContainer): void
    • Parameters

      • adContainer: HTMLElement

      Returns void

onAdsManagerAvailable?: ((adsManager) => void)

Callback that provides access to the google.ima.AdsManager.

Type declaration

    • (adsManager): void
    • Parameters

      • adsManager: any

      Returns void

placeholders?: AdTagPlaceholders

List of placeholder strings that will be replaced in the ad manifest URL with the corresponding values.

Since

8.1.0

sdkUrl?: string

The URL of the Google IMA Framework.

Default URL: https://imasdk.googleapis.com/js/sdkloader/ima3.js

strategy?: RestrictStrategy

Defines an object with two functions which will be called if an ad break is about to start or when ads are seeked over. If this property is not set manually, then only the last ad that was seeked over will be played.

trackers?: Trackers

Defines tracker configurations for the relevant packages such as the Open measurement which will be loaded to provide additional tracking information for ads.

videoLoadTimeout?: number

Specifies the amount of milliseconds before the loading of an ad from a given ad manifest times out. Default is 8000.

withCredentials?: boolean

Specifies whether to send credentials such as cookies or authorization headers along with the ad requests. The server needs to explicitly accept them for CORS requests, otherwise the request will fail. Default is true.