Overview: Below is information regarding how publishers can integrate with the IRIS.TV Context Script for the Contextual Video Marketplace. The Context Script gives publishers the ability to retrieve contextual information for a given video asset. This is meant to be used as a part of your existing ad workflow to send contextual data through your ad server. This documentation will walk through how to add the Context Script and workflows for adding the data to your ad tags.
See an example implementation page here: https://ovp.iris.tv/demos/context/iris-context-api.html
Prerequisites
Before adding the Context Script the following needs to be completed:
This workflow requires two values:
client_token: Authentication string associated with each client. This will be provided by IRIS.TV once the content feed is imported.
platform_id: The reference ID for the asset from the publisher’s CMS.
Building the Integration
The order of operations for retrieving the contextual data is as follows:
IRIS.TV Context Script is loaded with the page.
The Context Script is initialized.
Call the Context Script with the platform_id for the asset that is about to play to receive the asset’s contextual segments.
Add the contextual segments to the pre-roll ad tag.
This process should be repeated as you iterate through the playlist.
Installing the Script
Add the following script to the top of your page: https://ovp.iris.tv/libs/context/iris-context.min.js
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 a platform_id to receive the context segment on the asset. These methods are:
getContext – requests the context information for the platform_id.
getVideoInfo – requests context category information for the platform_id.
Parameters for these methods:
platform_id: the CMS reference ID of the asset. Required.
Please confirm with your IRIS.TV representative
Where the context field should be added within the ad tag (i.e. in the “cust_params” field in a DFP tag).
getContext
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", "segment_3"] }