This documentation details how clients using IRIS.TV Adaptive Stream can access context for ad targeting.
Clients that are using JW Player or Brightcove OVPs and serving ads in-player using the IMA ad plugin can find documentation here:
Clients that are using a non-IMA ad plugin, not using Brightcove or JW Player, or serving their ads on-page instead of in-player should follow the instructions below.
Two Methods to Access Context
Get context information for an asset using the “getPlaylist” function.
Get context information using our built-in CustomParmas Function. (Does not support publishers with multiple players on a single page.)
Both of these methods support access to the “context” and “iab” fields. The Context field will contain an encrypted context string (ex. “e883d22ce29c85f9e910281d2a410c5bad77a098”). The IAB field will contain an IAB code (ex. “IAB17-26”). Please check with your IRIS.TV representative on which field will be used for your assets’ context.
Note: These both require using the “global” plugin option listed in Adaptive Plugin UI Settings and Customization Options under the header Advanced Options. Options should not include “enable_context_ads” or “enable_category_ads” when using custom integration.
Context using the “getPlaylist” Function
Using this requires using the “getPlaylist” and “getCurrentIndex” functions described here: Adaptive Plugin Development Options.
Retrieving the Context or IAB data
Once the plugin has loaded, you can get the ad context for the next video by checking the “getPlaylist” function.
Here’s an example of pulling the context and IAB for the 1st recommended asset (with “iris” global_parameter set):
const playlistItem = iris.getPlaylist()[1]; playlist.context // context: ["e883d22ce29c85f9e910281d2a410c5bad77a098"] playlist.iab // iab: ["IAB17-26"]
As the viewer watches assets, you can check the current index of the player using “getCurrentIndex” and then request the context data for the next video in the playlist. An example of how to use “getCurrentIndex” to access the next video in the playlist can be found at Adaptive Plugin Development Options under the header Accessing the IRIS.TV Playlist.
Retrieving Context or IAB Data with a Multi-Player Pages
If you have multiple players on a page, then you should use the eID functionality documented here: Adaptive Plugin Development Options. This gives you the ability to specify a player instance with the global ID.
Here’s an example of how to use the eID functionality to pull context and IAB for the 1st recommended asset (with “iris” global_parameter set):
Query for the player’s eID:
Query for the eID with
window.irisInstances
An example of that function's response:
0: Object { id: "myPlayer", eid: "gXKM" } 1: Object { id: "myPlayer2", eid: "iAxr" } length: 2
2. Pull the context:
const playlistItem = iris.getPlaylistByEid("gXKM"))[1]; playlist.context // context: ["e883d22ce29c85f9e910281d2a410c5bad77a098"] playlist.iab // iab: ["IAB17-26"]
NOTE: The IRIS Adaptive Playlist will update dynamically based on user interaction.
Populating the Ad Tag with Context or IAB Data
Once that data is pulled, you can add it to the ad tag URL. The “context” is used to populate the “cust_params” field in a DFP ad tag. The “iab” is then used to populate the “categories” field.
Context Using IRIS Adaptive Plugin’s CustomParms Function
Does not support publishers with multiple players on a single page.
If you aren’t able to manually add the data to the ad tag URL, the IRIS adaptive plugin has a function to populate that data for you. This function is addCustomParamsToUrl
. You can send in a tag along, specify if you want to populate context in the cust_params
parameter or populate iab
in the categories
parameter.
The function looks like this:
iris.addCustomParamsToUrl(adTagUrl, 'context', { index: 1, eid: 'iAxr' }); iris.addCustomParamsToUrl(adTagUrl, 'category', { index: 1, eid: 'iAxr' }); iris.addCustomParamsToUrl(adTagUrl, 'category_cust_params', { index: 1, eid: 'iAxr' });
Parameters Required for CustomParams function:
adTagUrl
REQUIRED: the ad tag that you want to populate the context or IAB data tocategory
orcontext
orcategory_cust_params
REQUIRED: specify if you want to add the “category” field with the IAB code OR if you want to add the “context” field in cust_params with the context hash. Last option is if you want to add the “category” field with the IAB code in the cust_params.extraParams
Optional: You can send an object containing the asset index or a different experience id, and you will use those values to populate the data,eid
is useful for when you have more than one player on the same page. If no index or eid is provided, the function will use the current playing asset and experienceId as the default.
This function gets an ad tag URL, appends the context or category to the provided ad tag URL, and returns the new URL with this value. You should then assign this to the place where your player reads this data from.
Demo page of addCustomParamsToUrl
function is here: https://ovp.iris.tv/demos/custom-integration/brightcove.html. View page source to see an explanation of how the code works.
Note: For both getPlaylist() and Built-in function, you will need to update the ad tag URL before the ad is requested.