Build DFP Video
Combines publisher-provided parameters with Prebid.js targeting parameters to build a DFP video ad tag URL that can be used by a video player.
pbjs.adServers.dfp.buildVideoUrl(options);
The DFP implementation of this function requires including the dfpAdServerVideo module in your Prebid.js build.
Arguments:
  • options: object

    Object to be passed.

    Option Object Parameters
    Field Scope Type Description
    adUnit Required Object The Prebid ad unit to which the returned URL will map.
    params Optional Object Querystring parameters that will be used to construct the DFP video ad tag URL. Publisher-supplied values will override values set by Prebid.js. See below for fields.
    url Optional String The video ad server URL. When given alongside params, the parsed URL will be overwritten with any matching components of params.
    bid Optional Object The Prebid bid for which targeting will be set. If this is not defined, Prebid will use the bid with the highest CPM for the adUnit.
    One or both of options.params and options.url is required. In other words, you may pass in one, the other, or both, but not neither.
    The optional.params object
    Option Object Parameters
    Field Scope Type Description Example
    iu Required String DFP ad unit ID. /19968336/prebid_cache_video_adunit
    cust_params Optional Object Key-value pairs merged with Prebid’s targeting values and sent to DFP on the video ad tag URL. {section: "blog", anotherKey: "anotherValue"}
    description_url Required String Describes the video. Required for Ad Exchange. Prebid.js will build this for you unless you pass it explicitly. http://www.example.com
    For more information on any of these params, see the DFP video tag documentation.
Examples
There are several different ways to build up your video URL, as shown in the examples below:
Using options.params only:

pbjs.requestBids({
    bidsBackHandler: function(bids) {
        var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
            adUnit: videoAdUnit,
            params: {
                iu: '/19968336/prebid_cache_video_adunit',
                cust_params: {
                    section: "blog",
                    anotherKey: "anotherValue"
                },
                hl: "en",
                output: "xml_vast2",
                url: "http://www.example.com",
            }
        });
        invokeVideoPlayer(videoUrl);
    }
});pbjs.adServers.dfp.buildVideoUrl(options);
				
Using options.url only:

var adserverTag = 'https://pubads.g.doubleclick.net/gampad/ads?'
+ 'sz=640x480andiu=/19968336/prebid_cache_video_adunitandimpl=sandgdfp_req=1'
+ 'andenv=vpandoutput=xml_vast2andunviewed_position_start=1andhl=enandurl=http://www.example.com'
+ 'andcust_params=section%3Dblog%26anotherKey%3DanotherValue';

var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
    adUnit: videoAdUnit,
    url: adserverTag
});
				
In the event of collisions, querystring values passed via options.params take precedence over those passed via options.url.
Response
Response Description
{ response: example }
  • param1: string

    String indicating some value that has to be passed as a string type.

  • param2: number

    Number indicating some value that has to be passed as a number type.

    Note: This number should be between 0 and infinity.