-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Debugging Module: Bid responses for various media types (+ TestBidder) #12720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
0c0b08e
ff7adf6
18c51d5
7379f8c
e94b789
1ee8306
bcd3b58
e38c31d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
banner: { | ||
sizes: [600, 500] | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this just to have something here? I think it should work with an empty object. |
||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const winningBid = bids[0]; | ||
const div = document.getElementById('banner'); | ||
let iframe = document.createElement('iframe'); | ||
iframe.frameBorder = '0'; | ||
div.appendChild(iframe); | ||
var iframeDoc = iframe.contentWindow.document; | ||
pbjs.renderAd(iframeDoc, winningBid.adId); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Banner ad</h5> | ||
<div id="banner"></div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
native: { | ||
image: { | ||
required: true, | ||
sizes: [600, 500], | ||
} | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const bid = bids[0]; | ||
const slot = document.getElementById('native'); | ||
const iframe = document.createElement('iframe'); | ||
Object.entries({ | ||
frameBorder: 0, | ||
marginWidth: 0, | ||
marginHeight: 0, | ||
width: 600, | ||
height: 500, | ||
scrolling: 'no', | ||
srcdoc: document.getElementById('native-template').innerHTML | ||
}).forEach(([prop, val]) => iframe.setAttribute(prop, val)); | ||
slot.appendChild(iframe); | ||
iframe.onload = () => pbjs.renderAd(iframe.contentDocument, bid.adId); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<template id="native-template"> | ||
<style> | ||
body { | ||
display: inline-block; | ||
} | ||
|
||
.container { | ||
display: inline-block; | ||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; | ||
font-size: 14px; | ||
line-height: 1.42857143; | ||
color: #333; | ||
background: #fff url(##hb_native_asset_id_0##) no-repeat center; | ||
background-size: cover; | ||
width: 600px; | ||
height: 500px; | ||
} | ||
|
||
</style> | ||
<div class="container"> | ||
</div> | ||
</template> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Native ad</h5> | ||
<div id="native"></div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<html> | ||
<head> | ||
<title>Prebid Test Bidder Example</title> | ||
<script src="https://cdn.jwplayer.com/libraries/l5MchIxB.js"></script> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
<script> | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
const adUnitCode = 'adUnit-0000'; | ||
|
||
const adUnits = [{ | ||
mediaTypes: { | ||
video: { | ||
playerSize: [640, 360] | ||
} | ||
}, | ||
code: adUnitCode, | ||
bids: [ | ||
{bidder: 'testBidder', params: {}} | ||
] | ||
}] | ||
|
||
pbjs.que.push(function () { | ||
|
||
/** | ||
* BID RESPONSE SIMULATION SECTION START | ||
* | ||
* This section handles simulating a bidder | ||
* that will always respond with bid responses. | ||
* | ||
* This part should not be present in production. | ||
*/ | ||
pbjs.registerBidAdapter(null, 'testBidder', { | ||
supportedMediaTypes: ['banner', 'video', 'native'], | ||
isBidRequestValid: () => true | ||
}); | ||
|
||
pbjs.setConfig({ | ||
debugging: { | ||
enabled: true, | ||
intercept: [ | ||
{ | ||
when: { | ||
bidder: 'testBidder', | ||
}, | ||
then: { | ||
creativeId: 'testCreativeId', | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
/** | ||
* BID RESPONSE SIMULATION SECTION END | ||
*/ | ||
|
||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
adUnitCodes: [adUnitCode], | ||
bidsBackHandler: function() { | ||
const bids = pbjs.getHighestCpmBids(adUnitCode); | ||
const winningBid = bids[0]; | ||
jwplayer("player").setup({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we put this in a renderer? https://docs.prebid.org/dev-docs/show-outstream-video-ads.html if |
||
playlist: "https://cdn.jwplayer.com/v2/media/hWF9vG66", | ||
autostart: "viewable", | ||
width: 640, | ||
height: 360, | ||
advertising: { | ||
client: "vast", | ||
schedule: [ | ||
{ | ||
vastxml: winningBid.vastXml, | ||
offset: 'pre' | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<h2>Prebid Test Bidder Example</h2> | ||
<h5>Video ad</h5> | ||
<div id="player"></div> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost nothing in any integration example should be left in production.