Skip to content

Commit

Permalink
example of single auction option
Browse files Browse the repository at this point in the history
  • Loading branch information
protonate committed Apr 14, 2017
1 parent 9c2f676 commit 0671e85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions integrationExamples/gpt/amp/amp_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1>Welcome to the mobile web</h1>
height="250"
layout="fixed"
type="doubleclick"
json='{"prebid":{"requestBidsDuration":750,"adUnits":[{"code":"/19968336/header-bid-tag-1","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}'
json='{"prebid":{"requestBidsDuration":1000,"adUnits":[{"code":"/19968336/header-bid-tag-1","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]},{"code":"/19968336/header-bid-tag-2","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}'
data-slot="/19968336/header-bid-tag-1">
</amp-ad>

Expand All @@ -64,7 +64,7 @@ <h1>Welcome to the mobile web</h1>
height="250"
layout="fixed"
type="doubleclick"
json='{"prebid":{"requestBidsDuration":750,"adUnits":[{"code":"/19968336/header-bid-tag-2","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}'
json='{"prebid":{"requestBidsDuration":1000,"adUnits":[{"code":"/19968336/header-bid-tag-1","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]},{"code":"/19968336/header-bid-tag-2","sizes":[[300,250],[300,600],[300,250],[100,100]],"bids":[{"bidder":"appnexusAst","params":{"placementId":"10433394","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}'
data-slot="/19968336/header-bid-tag-2">
</amp-ad>

Expand Down
31 changes: 17 additions & 14 deletions integrationExamples/gpt/amp/remote.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}

function getTargeting(slot) {
var targeting = window.pbjs.getAdserverTargeting()[slot];
var targeting = window.context.master.pbjs.getAdserverTargeting()[slot] || {};
for (var key in targeting) {
if (targeting.hasOwnProperty(key)) {
targeting[key] = [targeting[key]];
Expand All @@ -87,10 +87,10 @@

function initAdserver() {
var i;
var adCalls = window.context.prebidAdCalls;
var adCallsLength = adCalls.length;
for (i = 0; i < adCallsLength; i++) {
adCalls.pop()();
var prebidAdCalls = window.context.master.prebidAdCalls;
var len = prebidAdCalls.length;
for (i = 0; i < len; i++) {
prebidAdCalls.pop()();
}
}

Expand All @@ -107,7 +107,9 @@
// Do nothing. No ad found.
}
if (data.adId) {
var adObject = window.pbjs._bidsReceived.find(function (bid) {
// AMP ads a `context` object to `window`s and that is used to find the
// `master` iframe where Prebid is loaded
var adObject = window.context.master.pbjs._bidsReceived.find(function (bid) {
return bid.adId === data.adId;
});

Expand All @@ -130,16 +132,17 @@
* iframes. For more info see: https://github.com/ampproject/amphtml/blob/e5501a30adf15c8fef049729f5e0e3137dbb18ca/3p/integration.js#L252
*/
draw3p(function(config, done) {
console.log('draw3p config: ', config);
if (config.prebid) {
if (typeof window.context.prebidAdCalls === 'undefined') {
window.context.prebidAdCalls = [];
if (typeof window.context.master.prebidAdCalls === 'undefined') {
window.context.master.prebidAdCalls = [];
}
var prebid = config.prebid;
adUnits = prebid.adUnits;
requestBidsDuration = prebid.requestBidsDuration;
window.context.prebidAdCalls.push(setTargeting.bind(null, config, done));
loadPrebidJS();
if (window.context && window.context.isMaster) {
var prebid = config.prebid;
adUnits = prebid.adUnits;
requestBidsDuration = prebid.requestBidsDuration;
loadPrebidJS();
}
window.context.master.prebidAdCalls.push(setTargeting.bind(null, config, done));
} else {
// if the slot doesn't have prebid config then fire callback
done(config);
Expand Down

0 comments on commit 0671e85

Please sign in to comment.