Configuration javascript code examples (before Prebid 9)
Simple adUnit configuration (for banner, native, outstream)
var adUnits = [ { // Declare you adunit code here code: "div-gpt-ad-1542984663788-0",
// Declare you mediatypes here mediaTypes: { // Mediatype: banner banner: { sizes: [[300, 250]], // Review supported sizes here }, // Mediatype: video (outstream) video: { context: "outstream", // We only support outstream at the moment api: [2, 7], // Your video player must at least support the value 2 and/or 7. playbackmethod: [6], // Highly recommended // ...Please add any other relevant OpenRTB 2.5 video options. }, // Mediatype: native native: { context: 1, plcmttype: 2, }, },
// Declare you Adagio parameters here bids: [ { bidder: "adagio", params: { organizationId: "1000", // Required site: "my-site", // Required placement: "pave_top", // Required adUnitElementId: "div-gpt-ad-1542984663788-0", // Recommended pagetype: "topic", // Optional }, }, ], },];Simple adUnit configuration (for instream)
var adUnits = [{ // Declare you adunit code here code: "div-gpt-ad-1542984663788-0",
// Declare you mediatypes here mediaTypes: {
// Mediatype: video (instream) video: { // Required params context: 'instream', playerSize: [ [640, 480] ], // All supported sizes. mimes: ['video/mp4', 'video/ogg', 'video/webm', 'application/javascript'], // Add these four mimes to optimise the performances. api: [1, 2, 3, 4, 5], // API frameworks either supported by a placement. You must support at least one value. plcmt: 1, // We require value '1'. See https://docs.prebid.org/dev-docs/pb9-notes.html#video-ortb2-objects
// Highly recommended params playbackmethod: [2], // Media playback methods. startdelay: 0, // Represents video start delay. protocols: [3, 6, 7, 8], // MediaCreativeSubtype represents subtypes of video ad creatives. }, },
// Declare you Adagio parameters here bids: [ { bidder: "adagio", params: { organizationId: "1000", // Required site: "my-site", // Required placement: "pave_top", // Required adUnitElementId: "div-gpt-ad-1542984663788-0", // Recommended pagetype: "topic", // Optional }, }, ],},];Full Prebid configuration example
<html>
<head> <script> window._iub = window._iub || {}; _iub.csConfiguration = { cookiePolicyId: 417383, siteId: 1, logLevel: "error", lang: "en", enableTcf: true, }; </script> <script src="//cdn.iubenda.com/cs/tcf/beta/stub.js"></script> <script async src="//cdn.iubenda.com/cs/beta/iubenda_cs.js"></script> <script async src="../../build/dev/prebid.js"></script> <script async src="//www.googletagservices.com/tag/js/gpt.js"></script>
<script> var PREBID_TIMEOUT = 700; var FAILSAFE_TIMEOUT = 2500;
var adUnits = [ { code: "div-gpt-ad-1460505748561-0", // !!! This div id is an example, you should refer to id in your html code mediaTypes: { banner: { sizes: [ [300, 250], [300, 600], ], }, },
// Replace this object to test a new Adapter! bids: [ { bidder: "adagio", params: { organizationId: "1002", site: "adagio-local-io", adUnitElementId: "div-gpt-ad-1460505748561-0", // !!! This div id is an example, you should refer to id in your html code placement: "banner_top", pagetype: "article", category: "economy" } }, ], }, ];
var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; </script>
<script> var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; googletag.cmd.push(function () { googletag.pubads().disableInitialLoad(); });
pbjs.que.push(function () { pbjs.addAdUnits(adUnits); pbjs.setConfig({ userSync: { filterSettings: { iframe: { bidders: ['adagio'], filter: 'include' } } } }); pbjs.bidderSettings = { adagio: { // scriptVersion: 'latest', storageAllowed: true } }; pbjs.enableAnalytics([{ provider: 'adagio' }]); pbjs.requestBids({ bidsBackHandler: sendAdserverRequest, timeout: PREBID_TIMEOUT, }); });
function sendAdserverRequest() { if (pbjs.adserverRequestSent) { console.log('early out'); return; } pbjs.adserverRequestSent = true; googletag.cmd.push(function () { pbjs.que.push(function () { pbjs.setTargetingForGPTAsync(); googletag.pubads().refresh(); }); }); }
setTimeout(function () { sendAdserverRequest(); console.log("timeout in main pbjs fired"); pbjs.adserverRequestSent = false; }, FAILSAFE_TIMEOUT); </script> <script> googletag.cmd.push(function () { googletag .defineSlot( "/19968336/header-bid-tag-0", [ [300, 250], [300, 600], ], "div-gpt-ad-1460505748561-0" // !!! This div id is an example, you should refer to id in your html code ) .addService(googletag.pubads());
googletag.pubads().enableSingleRequest(); googletag.enableServices(); }); </script></head>
<body> <h2>Prebid.js Test</h2> <h5>Div-1</h5> <div id="div-gpt-ad-1460505748561-0"> <script type="text/javascript"> googletag.cmd.push(function () { googletag.display("div-gpt-ad-1460505748561-0"); // !!! This div id is an example, you should refer to id in your html code }); </script> </div></body>
</html>