This example uses a test version of Prebid.js hosted on our CDN that is not recommended for production use. It includes all available adaptors. Production implementations should build from source or customize the build using the Download page to make sure only the necessary bidder adaptors are included.
Line 31 to 59: Customize ad server targeting keywords
In this example, the keywords sent to DFP are changed from the default hb_pb to custom_bid_price_key. It also customized the bid price from default pbMg to custom logic. The logic is:
Send $0.01 granularity price when the bid price is between $0 to $3.
Send $0.10 granularity price when the bid price is between $3 to $5.
Send $0.50 granularity price when the bid price is between $5 to $20.
Send $20.00 as the keyword value for any bids above $20.
This logic may be driven by the effort to reduce the number of line items while capturing the most accurate bid prices.
You can see the effect of this customization if you click into the Result tab of this JSFiddle gadget.
Line 84 to 87: Set targeting with custom keywords
pbjs.setTargetingForGPTAsync() will now use your custom keywords for targeting. The keywords can also be retrieved from calling pbjs.getTargetingForGPTAsync(). The result can be found in the Result tab of this JSFiddle gadget, and we’ve also copied it below: