Created
February 14, 2019 15:44
-
-
Save gpolaert/83cb66a28e3417e08f185c83846ffb11 to your computer and use it in GitHub Desktop.
Prebid / Multiple aliases example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta name="viewport" content="width=device-width, minimum-scale=0.1"> | |
| <title>Demo</title> | |
| <script src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script> | |
| <script> | |
| const adUnits = [ | |
| { | |
| code: 'banner-div-1', | |
| mediaTypes: { | |
| banner: { | |
| sizes: [[728, 90], [300, 600]], | |
| }, | |
| }, | |
| bids: [ | |
| { | |
| bidder: 'alias-appnexus-1', | |
| params: { | |
| placementId: 13144370, | |
| }, | |
| }, | |
| { | |
| bidder: 'alias-appnexus-2', | |
| params: { | |
| placementId: 13144370, | |
| }, | |
| }, | |
| { | |
| bidder: 'alias-appnexus-3', | |
| params: { | |
| placementId: 13144370, | |
| }, | |
| }], | |
| }, | |
| { | |
| code: 'banner-div-2', | |
| mediaTypes: { | |
| banner: { | |
| sizes: [[300, 600], [300, 600]], | |
| }, | |
| }, | |
| bids: [ | |
| { | |
| bidder: 'alias-appnexus-1', | |
| params: { | |
| placementId: 13144370, | |
| }, | |
| }, | |
| { | |
| bidder: 'alias-appnexus-2', | |
| params: { | |
| placementId: 13144370, | |
| }, | |
| }, | |
| ], | |
| }, | |
| ]; | |
| var pbjs = pbjs || {}; | |
| pbjs.que = pbjs.que || []; | |
| pbjs.que.push(() => { | |
| pbjs.setConfig({ debug: true }); | |
| pbjs.aliasBidder('appnexus', 'alias-appnexus-1'); | |
| pbjs.aliasBidder('appnexus', 'alias-appnexus-2'); | |
| pbjs.aliasBidder('appnexus', 'alias-appnexus-3'); | |
| pbjs.bidderSettings = { | |
| 'alias-appnexus-1': { | |
| bidCpmAdjustment: () => Math.random(), | |
| }, | |
| 'alias-appnexus-2': { | |
| bidCpmAdjustment: () => Math.random(), | |
| }, | |
| 'alias-appnexus-3': { | |
| bidCpmAdjustment: () => Math.random(), | |
| }, | |
| }; | |
| pbjs.addAdUnits(adUnits); | |
| pbjs.requestBids({ | |
| bidsBackHandler: (responses) => { | |
| Object.keys(responses).forEach(adUnit => { | |
| const ads = pbjs.getHighestCpmBids(adUnit); | |
| ads.forEach(ad => { | |
| document.write('<h1>' + adUnit + '@' + ad.bidderCode + '</h1>'); | |
| const iframe = document.createElement('iframe'); | |
| document.body.appendChild(iframe); | |
| pbjs.renderAd(iframe.contentWindow.document, ad.adId); | |
| }); | |
| }); | |
| }, | |
| timeout: 3000, | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body></body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment