View as Markdown

Prebid.js dynamic creatives

Overview

For line items that target browsers only, you may use Prebid.js dynamic creatives as an alternative to Prebid Universal Creative. The former provides slightly better performance and ease of use, but relies on Prebid.js, meaning that it does not support non-JS use cases (such as mobile apps or AMP).

Comparison vs PUC for Prebid.js

A creative set up to use Prebid Universal Creative:

  • loads a separate script, typically from a CDN; the script contains various rendering routines, including some specific to Prebid.js;
  • if the script determines that the ad render was initiated by Prebid.js, it retrieves from it information about the winning bid and renders it;
  • requires different setups for different use cases (such as banner vs native).

A Prebid.js dynamic creative:

  • does not load any additional script - it’s instead set up with a small block of inline Javascript;
  • it expects to always find Prebid.js, retrieving from it information about the winning bid and the rendering logic to use for it;
  • uses the same setup for all cases - but does not work when the render is not initiated by Prebid.js.

How to use

Dynamic creatives require Prebid.js version 8.36 or higher.

Set up the creative following this example. If you are not using GAM, replace the macros in the second script tag with appropriate equivalents.

Since Prebid.js 11.27, any fields passed to pbRender besides adId and pubUrl are forwarded to Prebid.js as render options. The example passes the GAM view-tracking URL as viewUrl: "%%VIEW_URL_UNESC%%"; Prebid.js stores it on the rendered bid as bid.viewUrl but does not fire it.

To render native ads, you also need to include the nativeRendering module in your Prebid.js bundle.

Click tracking

Since Prebid.js 11.50, the dynamic creative can register banner clicks in GAM (experimental: the counts are not expected to match GAM’s or the bidder’s exactly): the example passes GAM’s click URL (clickUrl: "%%CLICK_URL_UNESC%%"), and with bidClickTracking and fireTrackers enabled, Prebid.js requests it when it observes a click on the winning creative. This banner-click mechanism does not apply to native creatives: native GAM clicks must still be tracked through the native template’s click links. It is not available with the Prebid Universal Creative. The dynamic creative is intended for browser-only line items; split any line item also serving AMP or Prebid Mobile before replacing PUC.

Further reading