Advertisement

Fine tune advertisment behavior, loading and timeouts

Set frequency cap for ads

Use the following code snippet to set a custom ad frequency setting on a per user level in a Targetvideo player. The setting expects an Integer which holds a value in hours to how long a user will need to wait until it gets another ad served. In the example below, the value is set to 5 which means that a viewer will get an ad served only once every 5 hours.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"480",
	"video":"VIDEO_ID", 
	"freqCap": 5
});

Get consent data from a hostile iframe

If you add the “use_tcfapi_locator”: true parameter to the embed code, the player will try to grab consent data from a hostile iframe and then use it for advertising purposes.

Example:

$bp("myDiv", {"id":"player_id","width":"480","height":"270","video":"video_id", “use_tcfapi_locator”: true  });

Banner ads display if player served through DFP

Banner ads display if player served through DFP

If the player is served through DFP, there may be occasional issues with displaying banner ads correctly. To resolve this, simply add the 'use_iframe_for_banners' parameter to the embed code.

Example:

$bp("myDiv", {"id":"player_id","width":"480","height":"270","video":"video_id", "use_iframe_for_banners": true  });

Display the number of configured ad pods

Include the showAdsCounter parameter in the embed code if you wish to display the number of configured ad pods. It's important to note a system limitation when dealing with VMAP ads. The player won't count the number of ads due to inability to predict the number of ads a VMAP tag might return. Instead, it reserves one slot for these ads, skipping the display of a specific number for VMAP tags.

While the player effectively counts one ad pod as a single ad, it won't display any specific message during the playback of a VMAP ad. For example, if there are three pods — initially a VMAP ad followed by two VAST tags — during the playback of the VMAP ad, no message will be displayed. However, for the subsequent two VAST tags, the message will indicate "Showing 2 of 3" during the second one and "Showing 3 of 3" during the third.

The ad counter will accurately track ads for each position in the player. Preroll ads, midrolls, and postrolls will show the number of ads when it's time for playback in these slots. However, if only one pod is configured for preroll, midroll, or postroll, no message will be displayed.

If there is no valid ad response, one slot will be reserved for a specific ad pod, even thought the ad won't be displayed.

Example:

$bp("myDiv", {"id":"player_id","width":"480","height":"270","video":"video_id", "showAdsCounter": true  });

Custom ad tag parameters

Adding a custom ad tag parameters you can fine tune advertising behavior.

Force specific ad parser

You can force what ad parser you want the player to use per ad tag by adding the following parameter to your ad tag like this:

Example:

//Append to the ad tag URL
&brid_parser=ima
//Append to the ad tag URL
&brid_parser=brid

Force insecure mode for VPAID ads

Certain VPAID ads need to be pushed through an insecure (friendly) iframe when served through Google IMA SDK to display properly. You can force this insecure mode by adding the following string to your ad tag URL call.

🚧

Warrning

Available only when using Google IMA SDK.

Example:

//Append to the ad tag URL
&brid_vpaidmode=insecure

Custom Ad timeout

You can change the default timeout the player has for ad tags by adding the following param to the end of your ad tag URL.

📘

Note

By default this timeout is set to 15 seconds.

Example:

//Append to the ad tag URL
&brid_adtimeout=20

By adding the above to your ad tag, you will tell the player to wait for 20 seconds before it considers a timeout for this ad tag.

Remove player if no ad is found or after an ad ends display

The following example uses .destroy() method to remove the player from the page once the ad has finished the playback or if and adError happened.

Example:

function do_on_error(){
    //Remove player and all dependencies
    $bp().destroy();
    console.log('error fired removing player');
    //Add custom code here
}

function do_on_adend(){
    //Remove player and all dependencies
    $bp().destroy();
    console.log('ad end fired removing player');
    //Add custom code here
}

$bp("myDiv", configObj,  function(){
    // adEnd fires each time an ad ends (even if it errors out or doesn't exist)
    this.on('adEnd', do_on_adend);
    // adError fires only if an ad errors out, this includes empty VAST responses
    this.on('adError', do_on_error);
});
$bp("myDiv", configObj);
$bp().on("adEnd", function(){
    //Remove player and all dependencies
    $bp().destroy();
    console.log('ad end fired removing player');
    //Add custom code here
});
$bp().on("adError", function(){
    //Remove player and all dependencies
    $bp().destroy();
    console.log('error fired removing player');
    //Add custom code here
});

Set a custom ad with the API

Use the code snippet below to instruct the player to use a custom ad. In the demo below we set a custom ad tag URL as the source of the ad (URL returns a valid VAST template) and set it to appear as a mid-roll on the 20th second of the video.

Example:

var Ad = {
        /**
        * Mobile will be called on mobile and desktop if desktop is empty. 
        * If the desktop property is populated, the ad tags under mobile will get called on mobile only.
        */
        "mobile": [adtag1, adtag2, adtag3], 
        // Will get called in succession on desktop
        "desktop": [adtag1, adtag2, adtag3],
        // Type 0 for pre roll,1 Midroll, 2 Postroll
        "adType": "1", 
        //Used for midrolls, can se s=seconds, i=interval, %=percentage of the video
  	    "adTimeType": "s",
        //Cuepoints where you want the midroll to occur, if multiple, comma separated.
        "cuepoints": "20, 30" 
    }
    function foo() {
        $bp('ID_OF_PLAYER_DIV').setAd(Ad,'video');
    }
$bp("myDiv", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID",
 "Ad": [
        {
            /**
             * Mobile will be called on both mobile and desktop if desktop is left empty or omitted 
             * If desktop property is populated, 
             * the ad tags under mobile will get called on mobile only
             * and desktop on desktop only.
             */
            "mobile": [adtag1, adtag2, adtag3], 
            // Will get called in succession on desktop
            "desktop": [adtag1, adtag2, adtag3],
            // Type 0 for pre roll, 1 Midroll, 2 Postroll
          	"adType": "0", 
        }
    ]
});
$bp("myDiv", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID",
 "Ad": [
        {
          	//Will get called in succession on both mobile and desktop if the desktop array is left empty or omitted.
            "mobile": [mobile_adtag1, mobile_adtag2], 
          	// Will get called in succession on desktop only
            "desktop": [desktop_adtag1, desktop_adtag2], 
            "adType": "0", // Type 0 for pre roll,1 Midroll, 2 Postrol
        }
    ]
});

Valid paramaters when setting an ad can be found here

Set sticky behavior for ad display only

Use the following code snippet to force the player to sticky only if a valid ad is received by the player.

📘

Note

Make sure that the player you are using has its sticky option enabled and that your player is set to autoplay.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"360",
	"video":"VIDEO_ID",
	"autoplayStickyAdOnly": true
});

Reset ad frequency counter on page refresh

You can use the following parameter resetFreqCounter: bool to force a player to reset its ad frequency counter on every page refresh.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"360",
	"video":"VIDEO_ID",
	"resetFreqCounter": true
});

Customize Prebid timeouts

Timeout for prebid

See the below example on how to set a custom timeout in ms for how long prebid should wait on a response from a bidder.

📘

Note

Default setting is 2000ms.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"360",
	"video":"VIDEO_ID",
	"prebid_timeout": 2500 //2.5 seconds
});

Amazon prebid

See the below example on how to set a custom timeout in ms for how long Amazon prebid should wait on a response.

📘

Note

Default setting is 3 seconds.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"360",
	"video":"VIDEO_ID",
	"a9_timeout": 2500
});

Show snapshot while loading an advertisement

By default, the player shows a black screen and an small loading ad pre-loader when trying to fetch an ad from an ad server. You can force the player to display a starting snapshot instead of a black screen by using the below parameter.

Example:

$bp("myDiv", {
	"id":"PLAYER_ID",
	"width":"640",
	"height":"360",
	"video":"VIDEO_ID",
	"showSnapshotOnLoadingAd":true
});