From 9c2f6760247b6afdd8e9ae17045974a163593542 Mon Sep 17 00:00:00 2001 From: protonate Date: Tue, 11 Apr 2017 16:18:16 -0700 Subject: [PATCH 1/2] load prebid per amp-ad iframe remove bidder setting, clean up PR adjust auction duration, clean up --- integrationExamples/gpt/amp/amp_page.html | 4 +-- integrationExamples/gpt/amp/remote.html | 44 +++++++++++++---------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/integrationExamples/gpt/amp/amp_page.html b/integrationExamples/gpt/amp/amp_page.html index 2e2931e9dd6..47dcb790f9c 100644 --- a/integrationExamples/gpt/amp/amp_page.html +++ b/integrationExamples/gpt/amp/amp_page.html @@ -55,7 +55,7 @@

Welcome to the mobile web

height="250" layout="fixed" type="doubleclick" - 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":"4799418","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":"4799418","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}' + 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"}}]}]}}' data-slot="/19968336/header-bid-tag-1"> @@ -64,7 +64,7 @@

Welcome to the mobile web

height="250" layout="fixed" type="doubleclick" - 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":"4799418","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":"4799418","dealId":"some deal!"}},{"bidder":"aol","params":{"network":"10077.1","placement":3671670}},{"bidder":"sovrn","params":{"tagid":"315045"}}]}]}}' + 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"}}]}]}}' data-slot="/19968336/header-bid-tag-2"> diff --git a/integrationExamples/gpt/amp/remote.html b/integrationExamples/gpt/amp/remote.html index 5b604c88a6b..583aa1aa381 100644 --- a/integrationExamples/gpt/amp/remote.html +++ b/integrationExamples/gpt/amp/remote.html @@ -25,7 +25,7 @@ From 0671e85caf7703b7278afc229686841564a4883d Mon Sep 17 00:00:00 2001 From: protonate Date: Fri, 14 Apr 2017 15:34:55 -0700 Subject: [PATCH 2/2] example of single auction option --- integrationExamples/gpt/amp/amp_page.html | 4 +-- integrationExamples/gpt/amp/remote.html | 31 +++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/integrationExamples/gpt/amp/amp_page.html b/integrationExamples/gpt/amp/amp_page.html index 47dcb790f9c..ac6a2bcd3fe 100644 --- a/integrationExamples/gpt/amp/amp_page.html +++ b/integrationExamples/gpt/amp/amp_page.html @@ -55,7 +55,7 @@

Welcome to the mobile web

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"> @@ -64,7 +64,7 @@

Welcome to the mobile web

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"> diff --git a/integrationExamples/gpt/amp/remote.html b/integrationExamples/gpt/amp/remote.html index 583aa1aa381..40404636061 100644 --- a/integrationExamples/gpt/amp/remote.html +++ b/integrationExamples/gpt/amp/remote.html @@ -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]]; @@ -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()(); } } @@ -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; }); @@ -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);