Skip to content

Commit

Permalink
Improvement/prebid iframes amp pages (prebid#1119)
Browse files Browse the repository at this point in the history
* load prebid per amp-ad iframe

remove bidder setting, clean up PR

adjust auction duration, clean up

* example of single auction option
  • Loading branch information
Nate Cozi authored and dluxemburg committed Jul 17, 2018
1 parent 3c8acf1 commit 8a55591
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 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":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":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":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":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
47 changes: 28 additions & 19 deletions integrationExamples/gpt/amp/remote.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<!-- start Prebid.js AMP integration -->

<script>
// The Prebid global must match Prebid.js setting
// The Prebid global must match Prebid.js setting. This example file is not preprocessed so below we refer to global as `pbjs`.
var $$PREBID_GLOBAL$$ = pbjs;
var prebidSrc = 'https://publisher.com:9999/build/dev/prebid.js';
var adUnits;
Expand Down Expand Up @@ -71,22 +71,26 @@
}

function getTargeting(slot) {
var targeting = window.context.master.pbjs.getAdserverTargeting()[slot];
var targeting = window.context.master.pbjs.getAdserverTargeting()[slot] || {};
for (var key in targeting) {
if (targeting.hasOwnProperty(key)) {
targeting[key] = [targeting[key]];
}
}
targeting['prebid_amp'] = ['true'];

if (Object.keys(targeting).length) {
// only set this key if prebid targeting is present
targeting['prebid_amp'] = ['true'];
}
return targeting;
}

function initAdserver() {
function initAdserver() {
var i;
var adCalls = window.context.master.adCalls;
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 Down Expand Up @@ -128,18 +132,23 @@
* iframes. For more info see: https://github.com/ampproject/amphtml/blob/e5501a30adf15c8fef049729f5e0e3137dbb18ca/3p/integration.js#L252
*/
draw3p(function(config, done) {
if (typeof window.context.master.adCalls === 'undefined') {
window.context.master.adCalls = [];
}
if (window.context && window.context.isMaster && config.prebid) {
var prebid = config.prebid;
adUnits = prebid.adUnits;
requestBidsDuration = prebid.requestBidsDuration;
loadPrebidJS();
if (config.prebid) {
if (typeof window.context.master.prebidAdCalls === 'undefined') {
window.context.master.prebidAdCalls = [];
}
window.context.master.adCalls.push(setTargeting.bind(null, config, done));
}, ['doubleclick'], ['publisher.com']);
// the first array contains ad networks used, the second domains allows to load this file in an iframe
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);
}
}, ['doubleclick', 'taboola'], ['publisher.com']);
// the first array contains ad networks used, the second contains domains allowed to load this file in an iframe

listenAdRequestFromCreative();
</script>
Expand Down

0 comments on commit 8a55591

Please sign in to comment.