forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from prebid/master
rebase
- Loading branch information
Showing
47 changed files
with
2,095 additions
and
367 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<!-- | ||
This page calls a single bidder for a single ad slot. | ||
It is a specialized example for adding floors to bids using the priceFloors Module | ||
It also makes a good test page for new adapter PR submissions. Simply set your server's Bid Params object in the | ||
bids array inside the adUnits, and it will use your adapter to load an ad. | ||
NOTE that many ad servers won't send back an ad if the URL is localhost... so you might need to | ||
set an alias in your /etc/hosts file so that you can load this page from a different domain. | ||
--> | ||
|
||
<html> | ||
|
||
<head> | ||
<script async src="../../build/dist/prebid.js"></script> | ||
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> | ||
<script> | ||
var FAILSAFE_TIMEOUT = 3300; | ||
var PREBID_TIMEOUT = 1000; | ||
var adUnits = [{ | ||
code: 'div-gpt-ad-51545-0', | ||
sizes: [[300, 250], [600, 500]], | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250], [600, 500]] | ||
} | ||
}, | ||
// Replace this object to test a new Adapter! | ||
bids: [{ | ||
bidder: 'ix', | ||
params: { | ||
siteId: '300', | ||
size: [300, 250] | ||
} | ||
}] | ||
}]; | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
</script> | ||
<script> | ||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
googletag.cmd.push(function () { | ||
googletag.pubads().disableInitialLoad(); | ||
}); | ||
|
||
pbjs.que.push(function () { | ||
pbjs.addAdUnits(adUnits); | ||
pbjs.setConfig({ | ||
floors: { | ||
enforcement: { | ||
floorDeals: false, //default to false | ||
bidAdjustment: true | ||
}, | ||
data: { // default if endpoint doesn't return in time | ||
currency: 'USD', | ||
skipRate: 5, | ||
modelVersion: 'BlackBerryZap', | ||
schema: { | ||
fields: ['gptSlot', 'mediaType', 'size'] | ||
}, | ||
values: { | ||
'*|banner|600x500': 6.5, | ||
'*|banner|300x250': 3.25, | ||
'*|video': 3.5 | ||
} | ||
} | ||
} | ||
}); | ||
pbjs.requestBids({ | ||
bidsBackHandler: sendAdserverRequest, | ||
timeout: PREBID_TIMEOUT | ||
}); | ||
}); | ||
|
||
function sendAdserverRequest() { | ||
if (pbjs.adserverRequestSent) return; | ||
pbjs.adserverRequestSent = true; | ||
googletag.cmd.push(function () { | ||
pbjs.que.push(function () { | ||
pbjs.setTargetingForGPTAsync(); | ||
googletag.pubads().refresh(); | ||
}); | ||
}); | ||
} | ||
|
||
setTimeout(function () { | ||
sendAdserverRequest(); | ||
}, FAILSAFE_TIMEOUT); | ||
|
||
</script> | ||
|
||
<script> | ||
googletag.cmd.push(function () { | ||
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-51545-0').addService(googletag.pubads()); | ||
|
||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h2>Prebid.js Test</h2> | ||
<h5>Div-1</h5> | ||
<div id='div-gpt-ad-51545-0'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function () { googletag.display('div-gpt-ad-51545-0'); }); | ||
</script> | ||
</div> | ||
</body> | ||
|
||
</html> | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,9 @@ | |
{ | ||
name: "criteo" | ||
}, | ||
{ | ||
name: "uid2" | ||
} | ||
], | ||
syncDelay: 5000, | ||
auctionDelay: 1000 | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import {registerBidder} from '../src/adapters/bidderFactory.js'; | ||
|
||
const BIDDER_CODE = 'addefend'; | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
hostname: 'https://addefend-platform.com', | ||
|
||
getHostname() { | ||
return this.hostname; | ||
}, | ||
isBidRequestValid: function(bid) { | ||
return (bid.sizes !== undefined && bid.bidId !== undefined && bid.params !== undefined && | ||
(bid.params.pageId !== undefined && (typeof bid.params.pageId === 'string')) && | ||
(bid.params.placementId !== undefined && (typeof bid.params.placementId === 'string'))); | ||
}, | ||
buildRequests: function(validBidRequests, bidderRequest) { | ||
let bid = { | ||
v: $$PREBID_GLOBAL$$.version, | ||
auctionId: false, | ||
pageId: false, | ||
gdpr_consent: bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString ? bidderRequest.gdprConsent.consentString : '', | ||
referer: bidderRequest.refererInfo.referer, | ||
bids: [], | ||
}; | ||
|
||
for (var i = 0; i < validBidRequests.length; i++) { | ||
let vb = validBidRequests[i]; | ||
let o = vb.params; | ||
bid.auctionId = vb.auctionId; | ||
o.bidId = vb.bidId; | ||
o.transactionId = vb.transactionId; | ||
o.sizes = []; | ||
if (o.trafficTypes) { | ||
bid.trafficTypes = o.trafficTypes; | ||
} | ||
delete o.trafficTypes; | ||
|
||
bid.pageId = o.pageId; | ||
delete o.pageId; | ||
|
||
if (vb.sizes && Array.isArray(vb.sizes)) { | ||
for (var j = 0; j < vb.sizes.length; j++) { | ||
let s = vb.sizes[j]; | ||
if (Array.isArray(s) && s.length == 2) { | ||
o.sizes.push(s[0] + 'x' + s[1]); | ||
} | ||
} | ||
} | ||
bid.bids.push(o); | ||
} | ||
return [{ | ||
method: 'POST', | ||
url: this.getHostname() + '/bid', | ||
options: { withCredentials: true }, | ||
data: bid | ||
}]; | ||
}, | ||
interpretResponse: function(serverResponse, request) { | ||
const requiredKeys = ['requestId', 'cpm', 'width', 'height', 'ad', 'ttl', 'creativeId', 'netRevenue', 'currency', 'advertiserDomains']; | ||
const validBidResponses = []; | ||
serverResponse = serverResponse.body; | ||
if (serverResponse && (serverResponse.length > 0)) { | ||
serverResponse.forEach((bid) => { | ||
const bidResponse = {}; | ||
for (const requiredKey of requiredKeys) { | ||
if (!bid.hasOwnProperty(requiredKey)) { | ||
return []; | ||
} | ||
bidResponse[requiredKey] = bid[requiredKey]; | ||
} | ||
validBidResponses.push(bidResponse); | ||
}); | ||
} | ||
return validBidResponses; | ||
} | ||
} | ||
|
||
registerBidder(spec); |
Oops, something went wrong.