Context Script

Details how publishers can integrate the Context Script to add contextual targeting data to your ad tags. This is for context-only publishers and is to be used as a part of your existing ad workflow.

Prerequisites

Before adding the Context Script the following needs to be completed:

  • A feed with video URLs needs to be provided for IRIS.TV to import and add contextual data to assets. Video asset URLs need to link to either MP4 or m3u8 files.

  • An ad tag that can be appended with iris_context custom key-value pair.

  • Ad targeting on the iris_context key-value pair needs to be set up through the ad server.

Please speak to your IRIS.TV representative for details on these requirements.

This workflow requires two values:

  • client_token: Authentication string associated with your asset library . This will be provided by IRIS.TV once the content feed is imported.

  • platform_id: The reference ID for the asset from your CMS.

Building the Integration

The order of operations for retrieving the contextual data is as follows:

  1. IRIS.TV Context Script is loaded with the page.

  2. The Context Script is initialized.

  3. Call the Context Script with the platform_id for the asset that is about to play to receive the asset’s contextual segments.

  4. Add the contextual segments to the pre-roll ad tag.

This process should be repeated as you iterate through the playlist.

 
 Installing the Script

NOTE: The script should be loaded as a high priority to ensure you can receive context information for the pre-roll of the initial asset.

An example of adding the script to your page HTML:

<script src=”https://ovp.iris.tv/libs/context/iris-context.min.js” type=”text/javascript”></script>

If you do not want to load the script as a high-priority, there is an event that you can listen to at the global changes to ensure that the context methods are available. An example of setting up that event listener:

window.addEventListener(‘IrisContextAPI’, function() { 
// window.IrisContextAPI is ready to be used
});

Initializing the Script

  • To initialize the script, provide your client token to the IrisContextAPI Object

var IrisContext = window.IrisContextAPI({
client_token: '<your client token here>'
});

Using the Script

Once the script is initialized, you can send in an asset ID to receive the context segment:

  • getContext – requests the context information for the asset ID.

Parameter for get_context methods:

  • platform_id: the CMS reference ID of the video. Required.

To retrieve the context use the following method:

IrisContext.getContext('<platform_id of video here>', function(data) { 
// data is ready to be used
// where data is an object of the form { context: [‘ctx-value’] }
console.log(data.context);
});

Here’s an example of the response from the Context Script for getContext:

{
platform_id: '6026440620001',
context: ["segment_1", "segment_2"]
}

After the Integration is Complete

Once the integration is complete and you’re receiving contextual segments, move on to A Contextual to the Ad Server in order to add the data into your existing ad workflow.