Overview: The Context Script gives publishers the ability to retrieve context and IAB category information on a given asset. This is mean meant to be used as a part of your ad workflow to send context data through your ad server. This documentation will walk through how clients using the Adaptive Plugin can add the Context Script and retrieve context or IAB category for the initial asset and IRIS.TV recommendations.
...
To initialize the script, provide your client token the following to the IrisContextAPI Object:
...
...
client_
...
token
...
- If you are using the
global
Adaptive Plugin option, add the value for theglobal
option to the initialize:initial platform_id for each player on the page
Code Block | ||
---|---|---|
| ||
var IrisContext = window.IrisContextAPI({ client_token: '<your client token here>', global platform_id: 'IrisInstance', // <<<< Same value as Iris Plugin global option }) |
...
<platform_id of the initial video>'
}); |
Using the Script
Once the script is initialized, you can send in the video ID of the initial video to retrieve context and IAB category information.
...
Code Block |
---|
IrisContext.getVideoInfo('<platform_id of videothe initial here>video>', function(data) { // data is ready to be used // where data is an object of the form { context: [‘context-value’], categories: [‘iab-value’], platform_id: 'platform-id-value' } console.log(data.context); console.log(data.categories); }); |
...
Call
getRecommendationsInfo
route as a part of callbacks for IRIS.TV /watch and /next API routes, which are exposed through the irisResponseReady event.You only need to create this event along with the getRecommendationsInfo route once
You need to send the e.detail.platform_id value as it is below
Store data returned from
getRecommendationsInfo
so it can be used to retrieve data each recommended video.On video load, query player for ID of the video and then query stored platform_id values for context or IAB categories.
Send context of IAB category data in the pre-roll ad call for the video.
Sample formatting of the getRecommendationInfo request
...
Code Block |
---|
window.addEventListener('iris_watchirisResponseReady', function (e) { IrisContext.getRecommendationsInfo(e.detail.platform_id).then(function(data) { // <data> will contain the information in the form of: /* { <platform_id>: { context: <value>, categories: <value> }, <platform_id>: { context: <value>, categories: <value> }, } */ }); }); |
Sample formatting of the getRecommendationInfo request (/next call)
Code Block |
---|
window.addEventListener('iris_next', function (e) {
IrisContext.getRecommendationsInfo().then(function(data) {
// <data> will contain the information in the form of:
/* {
<platform_id>: { context: <value>, iab: <vlaue> },
<platform_id>: { context: <value> },
}
*/
});
}); |