-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prebid:master' into master
- Loading branch information
Showing
322 changed files
with
18,515 additions
and
5,066 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 |
---|---|---|
|
@@ -92,4 +92,4 @@ <h5>Div-1</h5> | |
</div> | ||
</body> | ||
|
||
</html> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<!-- | ||
This page calls a single bidder for a single ad slot. It can be considered a "hello world" example for using | ||
Prebid with the Google Publisher Tag. | ||
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> | ||
<title>NexVerse Prebid.Js Demo</title> | ||
<script async src="../../build/dev/prebid.js"></script> | ||
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script> | ||
<script> | ||
var FAILSAFE_TIMEOUT = 3300; | ||
var PREBID_TIMEOUT = 1000; | ||
|
||
var adUnits = [{ | ||
code: 'div-banner-native-1', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[970, 90]], | ||
} | ||
}, | ||
|
||
// Replace this object to test a new Adapter! | ||
bids: [{ | ||
bidder: 'nexverse', | ||
params: { | ||
uid: '77d4a2eb3d209ce6c7691dc79fcab358', | ||
pubId: '24051', | ||
pubEpid: '34561' | ||
}, | ||
isDebug: false // Optional, i.e True for debug mode | ||
}] | ||
|
||
},{ | ||
code: 'div-banner-native-2', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]], | ||
} | ||
}, | ||
|
||
// Replace this object to test a new Adapter! | ||
bids: [{ | ||
bidder: 'nexverse', | ||
params: { | ||
uid: '77d4a2eb3d209ce6c7691dc79fcab358', | ||
pubId: '24051', | ||
pubEpid: '34561' | ||
}, | ||
isDebug: false // Optional, i.e True for debug mode | ||
}] | ||
|
||
}]; | ||
|
||
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.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', [[970, 90]], 'div-banner-native-1').addService(googletag.pubads()); | ||
googletag.defineSlot('/19968336/header-bid-tag-1', [[300, 250]], 'div-banner-native-2').addService(googletag.pubads()); | ||
|
||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<h2>Nexverse Prebid.js Test</h2> | ||
<h5>Div-1</h5> | ||
<div id='div-banner-native-1'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function () { googletag.display('div-banner-native-1'); }); | ||
</script> | ||
</div> | ||
|
||
<h5>Div-2</h5> | ||
<div id='div-banner-native-2'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function () { googletag.display('div-banner-native-2'); }); | ||
</script> | ||
</div> | ||
</body> | ||
|
||
</html> |
114 changes: 114 additions & 0 deletions
114
integrationExamples/gpt/rewardedInterestIdSystem_example.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<title>Rewarded Interest ID Example</title> | ||
<script> | ||
const FAILSAFE_TIMEOUT = 2000; | ||
const adUnits = [ | ||
{ | ||
code: 'test-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250], [300, 600], [728, 90]] | ||
}, | ||
}, | ||
bids: [ | ||
{ | ||
bidder: 'rubicon', | ||
params: { | ||
accountId: '1001', | ||
siteId: '113932', | ||
zoneId: '535510' | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
</script> | ||
<script src="../../build/dev/prebid.js" async></script> | ||
|
||
<script> | ||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
googletag.cmd.push(function () { | ||
googletag.pubads().disableInitialLoad(); | ||
}); | ||
|
||
pbjs.que.push(function () { | ||
pbjs.setConfig({ | ||
debug: true, | ||
userSync: { | ||
userIds: [ | ||
{ | ||
name: 'rewardedInterestId', | ||
}, | ||
], | ||
syncDelay: 5000, | ||
auctionDelay: 1000, | ||
} | ||
}); | ||
pbjs.addAdUnits(adUnits); | ||
pbjs.requestBids({ | ||
bidsBackHandler: sendAdserverRequest | ||
}); | ||
}); | ||
|
||
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> | ||
(function () { | ||
var gads = document.createElement('script'); | ||
gads.async = true; | ||
gads.type = 'text/javascript'; | ||
gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; | ||
var node = document.getElementsByTagName('script')[0]; | ||
node.parentNode.insertBefore(gads, node); | ||
})(); | ||
</script> | ||
|
||
<script> | ||
googletag.cmd.push(function () { | ||
googletag.defineSlot('/112115922/FL_PB_MedRect', [[300, 250], [300, 600], [728, 90]], 'test-div').addService(googletag.pubads()); | ||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
pbjs.que.push(function () { | ||
pbjs.getUserIdsAsync().then(ids => { | ||
document.getElementById('ids-div').innerHTML = JSON.stringify(ids, null, ' '); | ||
document.getElementById('eids-div').innerHTML = JSON.stringify(pbjs.getUserIdsAsEids(), null, ' '); | ||
}); | ||
}); | ||
</script> | ||
|
||
<h2>Rewarded Interest ID Example</h2> | ||
|
||
<h4>Generated IDs:</h4> | ||
<pre id="ids-div" style="border:1px solid #333; padding:5px; overflow: auto"></pre> | ||
|
||
<h4>Generated EIDs</h4> | ||
<pre id="eids-div" style="border:1px solid #333; padding:5px; overflow: auto"></pre> | ||
</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
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,78 @@ | ||
import { isEmpty, parseUrl } from '../../src/utils.js'; | ||
import {config} from '../../src/config.js'; | ||
import { createNativeRequest, createBannerRequest, createVideoRequest } from './index.js'; | ||
import { convertOrtbRequestToProprietaryNative } from '../../src/native.js'; | ||
|
||
export const buildRequests = (validBidRequests, bidderRequest, endpointURL, defaultCur) => { | ||
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests); | ||
if (!validBidRequests.length || !bidderRequest) return []; | ||
|
||
const endpoint = endpointURL.replace('hash', validBidRequests[0].params.placementId); | ||
const imp = validBidRequests.map((br) => { | ||
const impObject = { id: br.bidId, secure: 1 }; | ||
if (br.mediaTypes.banner) impObject.banner = createBannerRequest(br); | ||
else if (br.mediaTypes.video) impObject.video = createVideoRequest(br); | ||
else if (br.mediaTypes.native) impObject.native = { id: br.transactionId, ver: '1.2', request: createNativeRequest(br) }; | ||
return impObject; | ||
}); | ||
|
||
const page = bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation; | ||
const data = { | ||
id: bidderRequest.bidderRequestId, | ||
cur: [defaultCur], | ||
device: { w: screen.width, h: screen.height, language: navigator.language?.split('-')[0], ua: navigator.userAgent }, | ||
site: { domain: parseUrl(page).hostname, page: page }, | ||
tmax: bidderRequest.timeout, | ||
imp, | ||
}; | ||
|
||
if (bidderRequest.refererInfo.ref) data.site.ref = bidderRequest.refererInfo.ref; | ||
if (bidderRequest.gdprConsent) { | ||
data.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; | ||
data.user = { ext: { consent: bidderRequest.gdprConsent.consentString || '' } }; | ||
} | ||
if (bidderRequest.uspConsent) data.regs.ext.us_privacy = bidderRequest.uspConsent; | ||
if (config.getConfig('coppa')) data.regs.coppa = 1; | ||
if (validBidRequests[0].schain) data.source = { ext: { schain: validBidRequests[0].schain } }; | ||
|
||
return { method: 'POST', url: endpoint, data }; | ||
}; | ||
|
||
export const interpretResponse = (serverResponse, defaultCur, parseNative) => { | ||
if (!serverResponse || isEmpty(serverResponse.body)) return []; | ||
|
||
let bids = []; | ||
serverResponse.body.seatbid.forEach(response => { | ||
response.bid.forEach(bid => { | ||
const mediaType = bid.ext?.mediaType || 'banner'; | ||
|
||
const bidObj = { | ||
requestId: bid.impid, | ||
cpm: bid.price, | ||
width: bid.w, | ||
height: bid.h, | ||
ttl: 1200, | ||
currency: defaultCur, | ||
netRevenue: true, | ||
creativeId: bid.crid, | ||
dealId: bid.dealid || null, | ||
mediaType, | ||
}; | ||
|
||
switch (mediaType) { | ||
case 'video': | ||
bidObj.vastUrl = bid.adm; | ||
break; | ||
case 'native': | ||
bidObj.native = parseNative(bid.adm); | ||
break; | ||
default: | ||
bidObj.ad = bid.adm; | ||
} | ||
|
||
bids.push(bidObj); | ||
}); | ||
}); | ||
|
||
return bids; | ||
}; |
Oops, something went wrong.