IMA SDK Adapter Integration Guide

The IMA Adapter allows you to use the IAS web video SDK in Campaign Monitoring mode with your ads running with the Google IMA SDK for HTML5.

Overview

Follow these instructions to integrate Integral Ad Science's (IAS's) web video SDK in Campaign Monitoring mode with your ads running with the Google IMA SDK for HTML5. After pulling in the accompanying JavaScript code, IAS's web video SDK can be initialized with macros.

IAS recommends using the IAS IMA SDK Adapter (vans-adapter-google-ima.js) hosted by IAS which ensures you always use the latest available version of the adapter.

Environmental requirements

Before going live, send IAS a page for test and sign-off. IAS performs certification tests to confirm the implementation qualifies for live campaigns. Therefore, when you keep these environmental features constant across implementations, you can use the integration on multiple pages without needing IAS to re-test.

Your integration must ensure the ad node provided to googleImaVansAdapter.init as the videoElement argument fulfills the following properties:

  • is a real HTML element ('adNode.nodeType === 1' should return 'true') and not a proxy object

  • is attached to the DOM (inserted into a rendered document) at the time SDK measurement is initialized

  • is without styling (on itself or on a container) that renders it invisible (such as dimensions of 0x0 (and overflow:none); display:none; visibility:hidden). You can ensure it is visible by checking that "adNode.getBoundingClientRect().width > 0 AND adNode.getBoundingClientRect().height > 0"

You must confirm the following is true of the document/environment that you initialize IAS measurement in:

  • window.document.readyState !== "loading" before and during playback

  • able to inject more elements into the page (under the ad node)

Important note on required arguments for initialization

Whether you can implement the IAS IMA SDK Adapter depends if the player SDK and IMA SDK integration you are using exposes the Google IMA google and adsManager objects to you. IAS expects you to satisfy one of the following use cases:

1) use a player's SDK with a built-in IMA SDK integration, or

2) use a player's SDK without a built-in IMA SDK integration, in which case you are implementing the IMA SDK integration external to the player

To initialize measurement, you need to provide the googleImaVansAdapter references to both the global google and the adsManager object from the Google IMA SDK integration to your player.

Use case #1 has two further possibilities:

1a) the player's IMA SDK built-in integration exposes the adsManager object to you through an API which allows you to implement the IAS IMA SDK Adapter. For example, the Brightcove player has player.ima3.adsManager and the JW Player has the player.on('adsManager', callback) event.

1b) the player SDK's IMA SDK built-in integration does not expose the adsManager object to you. Rather than implement a workaround, IAS recommends you work with your IAS representative to determine the best course of action, whether that is working with the player SDK developer to expose the adsManager object, or switching to a player that does expose the adsManager object.

In use case #2, since you are working with the IMA SDK directly, google and adsManager are exposed to you, and therefore you can implement the IAS IMA SDK Adapter.

Use Case

adsManager exposed to you

Can implement IAS IMA SDK Adapter

1a

Yes

Yes

1b

No

No, contact IAS

2

Yes

Yes

Step One

Include the script tag in your HTML:

<script type="text/javascript" src="https://static.adsafeprotected.com/vans-adapter-google-ima.js"></script>

Note: This tag must be included after the IMA SDK <script> tag for the integration to work.

Step Two

After initializing the Google IMA SDK for HTML5, initialize the IAS adapter in a callback to the Google IMA SDK's google.ima.AdsManagerLoadedEvent. First, create a config object containing the macros and IDs that will be passed to IAS to enable campaign monitoring.

You must use the anId values IAS gave you and the size of the ad (via campId) in the config object.

Here is an example of a valid config object containing all the required macros:

var configWithAllRequiredProperties = {
anId: 'AD-NETWORK-ID-PROVIDED-BY-YOUR-IAS-REP',
campId: 'PROVIDE-YOUR-OWN-SIZE'
};

You can optionally include additional data and IDs in your reporting through additional macros (listed in the table below) in your config object.

  • All macros listed in the table below are tracked by IAS log-level reporting

  • If you need to pass other data to be tracked, you may remap the macro fields that are not required for initialization

  • IAS does not track any other arbitrary data passed as config properties

Here is an example of another valid config object containing required and optional macros:

var configWithRequiredPropsAndMacros = {
anId: 'AD-NETWORK-ID-PROVIDED-BY-YOUR-IAS-REP',
campId: 'PROVIDE-YOUR-OWN-SIZE',
chanId: 'PROVIDE-YOUR-OWN-AD-UNIT-ID',
pubOrder: 'PROVIDE-YOUR-OWN-VIDEO-ORDER',
// when non-AdX creatives
pubId: 'PROVIDE-YOUR-OWN-ADVERTISER',
custom: 'YOUR-CUSTOM-MACRO-1',
custom2: 'YOUR-CUSTOM-MACRO-2',
ias_xps: 'YOUR-AUTOPLAY-PREFERENCE', //optional
ias_xbp: 'YOUR-BREAKPOSITION-PREFERENCE', //optional
ias_xar: 'YOUR-AUTOREFRESH-PREFERENCE' //optional
};

IDs available from IMA (line item ID placementId, creative ID pubCreative, and advertiser ID pubId) supplied by the adapter overwrite any values for those keys (placementId, pubCreative, and pubId) that you pass into your config.

Note: Provide as many of the optional configuration macros as possible.

All the macros are a string data type. The following table shows you the various macros, how the macro appears in the IAS UI, whether you must supply this in your implementation, and if the macro is available in IMA and populated by IAS:

Macro

Required?

IAS UI Field

For you to pass

In IMA and IAS populated

Description

anId

Yes

Not applicable

Yes

No

An ad Network ID which IAS provides. You must pass the ad network ID supplied by IAS to ensure reporting behaves properly.

campId

Yes

Size

Yes

No

The size/dimensions of the ad, for example, '640x360'.

chanId

No

Ad Unit

Yes

No

Ad Unit ID

pubOrder

No

Order

Yes

No

Not provided by IMA. You may leave blank or hard code to a value, for example, 'Video Orders'.

placementId

No

Line Item

No

Yes

IAS populates this value as either the DFP line item ID for DFP ads only, or the AdX deal ID for AdX ads only. Otherwise, you may leave blank or hard code to a value like "Video Line Items".

pubCreative

No

Creative

No

Yes

The DFP master creative ID provided by IMA for DFP ads only.

pubId

No

Advertiser

Yes

Yes

The advertiser ID for AdX creatives. This value is set to "AdX" when the creative serves from AdX; otherwise, the value is blank for non-AdX creatives. You can pass in an advertiser name when working with non-AdX creatives, for example, "Direct".

custom

No

(Varies according to your implementation

Yes

No

Custom macro (for example, traffic source, page type, etc.). Generally, this is a DFP key/value. If custom macros are in use for display inventory, the same should be provided for video for consistent reporting.

custom2

No

(Varies according to your implementation

Yes

No

Custom macro (for example, traffic source, page type, etc.). Generally, this is a DFP key/value. If custom macros are in use for display inventory, the same should be provided for video for consistent reporting.

custom3

No

(Varies according to your implementation

Yes

No

Custom macro (for example, traffic source, page type, etc.). Generally, this is a DFP key/value. If custom macros are in use for display inventory, the same should be provided for video for consistent reporting.

ias_xps

Yes

Not in UI

Yes

No

Autoplay or click-to-play. Optional. Possible values include: "autoplayed" or "clicktoplay"

ias_xbp

Yes

Not in UI yet

Yes

No

Break position (when in a video that ad played). Optional. Possible values include: "1" - pre-roll, "2" - mid-roll, "3" - post-roll, or "4" - stand-alone

ias_xar

Yes

Not in UI

Yes

No

Autorefresh. Optional. Possible values include: "0" - false or "1" - true

Step Three

In the same script, inside the callback for google.ima.AdsManagerLoadedEvent, initialize IAS's web video SDK with the googleImaVansAdapter.init function (made available to you by the script from Step One). Supply as arguments the global google object, the IMA adsManager, the video HTML element for your player, and the config object created in the previous step.

Note: perform all initialization of the IAS Google IMA Adapter for your IMA player script inside the 'onAdsManagerLoaded' callback. The callback function is the only place where modification is needed to initialize the IAS adapter code.

function onAdsManagerLoaded(adsManagerLoadedEvent) {
// Get a reference to an HTML element (nodeType 1 && width/height > 0)
// representing the ad
var videoElement = document.getElementById('video-player');
// Get the adsRenderingSettings to get the 'adsManager'
var adsRenderingSettings = new google.ima.AdsRenderingSettings();
// Get the adsManager
var adsManager = adsManagerLoadedEvent.getAdsManager(videoElement, adsRenderingSettings);
// Create your config object
var config = {
partner: 'YOUR-IAS-PROVIDED-PARTNER-CODE',
anId: 'AD-NETWORK-ID-PROVIDED-BY-YOUR-IAS-REP',
campId: 'PROVIDE-YOUR-OWN-SIZE',
chanId: 'PROVIDE-YOUR-OWN-AD-UNIT-ID',
pubOrder: 'PROVIDE-YOUR-OWN-VIDEO-ORDER',
// when non-AdX creatives
pubId: 'PROVIDE-YOUR-OWN-ADVERTISER',
custom: 'YOUR-CUSTOM-MACRO-1',
custom2: 'YOUR-CUSTOM-MACRO-2',
ias_xps: 'YOUR-AUTOPLAY-PREFERENCE', // video context parameter for autoplay status, optional
ias_xbp: 'YOUR-BREAKPOSITION-PREFERENCE', // video context parameter for video placement type, optional
ias_xar: 'YOUR-AUTOREFRESH-PREFERENCE' // video, optional
};
// Init IAS Integration
googleImaVansAdapter.init(google, adsManager, videoElement, config);
}

Example

Check your implementation against this example:

index.html

<!DOCTYPE html>
<html>
<head>
<title>My IAS-IMA Integration</title>
<script type="text/javascript" src="https://imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<script type="text/javascript" src="https://static.adsafeprotected.com/vans-adapter-google-ima.js"></script>
<script type="text/javascript" src="path/to/imaPlayerInit.js"></script>
</head>
<body>
<div id="ad-slot" style="width: 480px;height: 250px">
<video id="video-player" width="480px" height="250px"></video>
</div>
<button id="play-button">Play</button> </body>
</html>

imaPlayerInit.js

function onAdsManagerLoaded(adsManagerLoadedEvent) {
// Get a reference to an HTML element (nodeType 1 && width/height > 0)
// representing the ad
var videoElement = document.getElementById('video-player');
// Get the adsRenderingSettings to get the 'adsManager'
var adsRenderingSettings = new google.ima.AdsRenderingSettings();
// Get the adsManager
var adsManager = adsManagerLoadedEvent.getAdsManager(videoElement, adsRenderingSettings);
// Create your config object
var config = {
anId: 'AD-NETWORK-ID-PROVIDED-BY-YOUR-IAS-REP',
campId: 'PROVIDE-YOUR-OWN-SIZE',
chanId: 'PROVIDE-YOUR-OWN-AD-UNIT-ID',
pubOrder: 'PROVIDE-YOUR-OWN-VIDEO-ORDER',
pubId: 'PROVIDE-YOUR-OWN-ADVERTISER', // when non-AdX creatives
custom: 'YOUR-CUSTOM-MACRO-1',
custom2: 'YOUR-CUSTOM-MACRO-2',
ias_xps: 'YOUR-AUTOPLAY-PREFERENCE', // video context parameter for autoplay status, optional
ias_xbp: 'YOUR-BREAKPOSITION-PREFERENCE', // video context parameter for video placement type, optional
ias_xar: 'YOUR-AUTOREFRESH-PREFERENCE' // video, optional
};
// Init IAS Integration
googleImaVansAdapter.init(google, adsManager, videoElement, config);
}
Was this article helpful?

Need further help?

Create an IAS case with details of your inquiry to receive help from our internal support team.