relevantDigital.defineVideoSlots()

This function creates video ad "slots" for instream video

For more explanations along with a complete example on how to use instream video with Google Ad Manager - please read this article: Instream video with HBM and GAM

Notice: This functionality is currently only available when using Google Ad Manager as ad server.

Parameters

An array of settings for the video slots. Each object can contain these fields:

  • path (mandatory) - The ad unit path in Google Ad Manager, example: "/12345/articles/pre_roll"
  • id - An "id" for the slot that can be used later in the call to relevantDigital.loadVideoUrls(). If not supplied one will be created automatically. Notice that this id must be unique per slot.
  • custParams - Custom parameters (targeting) for the ad server.

Return value

An array of VideoSlot objects, one for each object in the parameter array. To get the id of one slot, use the [videoSlot].getSlotElementId() function.

Example

window.relevantDigital = window.relevantDigital || {};
relevantDigital.cmd = relevantDigital.cmd || [];
relevantDigital.cmd.push(() => {
  const videoSlots = relevantDigital.defineVideoSlots([
      {
path: '/12345/articles/pre_roll',
id: 'preroll_1',
custParams: { 'section': 'articles' },
},
    {
path: '/12345/articles/pre_roll',
id: 'preroll_2',
         custParams: { 'section': 'articles' },
         },
  ]);
    

  // Call relevantDigital.loadPrebid() "as normal"
  relevantDigital.loadPrebid({ ... });
    
  // Get the URLs with VAST XML that should be used with the video player
relevantDigital.loadVideoUrls(['preroll_1', 'preroll_2'], (vastUrls) => {
console.info('VAST URLs:', vastUrls);
// TODO: Invoke video player here
});
});