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 Brid 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
});

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 = {
        "adTagUrl": ['https://an.facebook.com/v1/instream/vast.xml?placementid=TEST_PLACEMENT_ID&pageurl=test.com', 'https://an.facebook.com/v1/instream/vast.xml?placementid=TEST_PLACEMENT_ID&pageurl=test.com'],
        "adType": "1",
        "adTimeType": "s",
        "overlayStartAt": null,
        "overlayDuration": null,
        "cuepoints": "20"
    }
    function foo() {
        $bp('ID_OF_PLAYER_DIV').setAd(Ad,'video');
    }
$bp("myDiv", {"id":"8341","width":"480","height":"270","video":"123411",
 "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
            "adType": "0",
            "adTimeType": "s"
        }
    ]
});
$bp("myDiv", {"id":"PLAYER_ID","width":"640","height":"360","video":"VIDEO_ID",
 "Ad": [
        {
            "mobile": ['https://an.facebook.com/v1/instream/vast.xml?placementid=TEST_PLACEMENT_ID&pageurl=test.com'], //Will get called in succession on mobile and desktop if the desktop array is left empty.
            "desktop": ['https://an.facebook.com/v1/instream/vast.xml?placementid=TEST_PLACEMENT_ID&pageurl=test.com'], // Will get called in succession on desktop only
            "adType": "0", // Type 0 for pre roll
            "adTimeType": "s",
            "overlayStartAt": null,
            "overlayDuration": null,
            "cuepoints": null
        }
    ]
});

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
});

Did this page help you?