forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #1 from harman-goei/openx
fix(prebid,arj): APPS-11501: Add Openx_Neo Adapter that utilizes ARJs
- Loading branch information
Showing
7 changed files
with
1,176 additions
and
27 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,156 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
|
||
<script> | ||
|
||
|
||
var PREBID_TIMEOUT = 700; | ||
|
||
var googletag = googletag || {}; | ||
googletag.cmd = googletag.cmd || []; | ||
// googletag.cmd.push(function () { | ||
// googletag.pubads().disableInitialLoad(); | ||
// }); | ||
|
||
/* pbjs.initAdserver will be called either when all bids are back, or | ||
when the timeout is reached. | ||
*/ | ||
function initAdserver() { | ||
if (pbjs.initAdserverSet) return; | ||
(function() { | ||
var gads = document.createElement('script'); | ||
gads.async = true; | ||
gads.type = 'text/javascript'; | ||
var useSSL = 'https:' == document.location.protocol; | ||
gads.src = (useSSL ? 'https:' : 'http:') + | ||
'//www.googletagservices.com/tag/js/gpt.js'; | ||
var node = document.getElementsByTagName('script')[0]; | ||
node.parentNode.insertBefore(gads, node); | ||
})(); | ||
pbjs.initAdserverSet = true; | ||
} | ||
|
||
// Load GPT when timeout is reached. | ||
setTimeout(initAdserver, PREBID_TIMEOUT); | ||
|
||
var pbjs = pbjs || {}; | ||
pbjs.que = pbjs.que || []; | ||
|
||
// Load the Prebid Javascript Library Async. We recommend loading it immediately after | ||
// the initAdserver() and setTimeout functions. | ||
(function () { | ||
var d = document; | ||
var pbs = d.createElement("script"); | ||
pbs.type = "text/javascript"; | ||
pbs.src = '/build/dev/prebid.js'; | ||
var target = d.getElementsByTagName("head")[0]; | ||
target.insertBefore(pbs, target.firstChild); | ||
})(); | ||
|
||
// //load GPT library here | ||
// (function () { | ||
// var gads = document.createElement('script'); | ||
// gads.async = true; | ||
// gads.type = 'text/javascript'; | ||
// var useSSL = 'https:' == document.location.protocol; | ||
// gads.src = (useSSL ? 'https:' : 'http:') + | ||
// '//www.googletagservices.com/tag/js/gpt.js'; | ||
// var node = document.getElementsByTagName('script')[0]; | ||
// node.parentNode.insertBefore(gads, node); | ||
// })(); | ||
|
||
|
||
pbjs.que.push(function() { | ||
pbjs.addAdUnits([{ | ||
code: 'div-gpt-ad-1394140255771-0', | ||
sizes: [[728, 90]], | ||
bids: [ | ||
{ | ||
bidder: 'openx', | ||
params: { | ||
unit: '1611032360', | ||
jstag_url: '//qa-v2-i63-auto-pmp.del-qa.openx.net/w/1.0/jstag?dbg=1&nc=90577858-harman_prebid' | ||
} | ||
} | ||
] | ||
}]); | ||
|
||
pbjs.requestBids({ | ||
bidsBackHandler: function() { | ||
initAdserver(); | ||
} | ||
}); | ||
|
||
function _getBucketFromCPM(cpm, bm) { | ||
if (!bm) { | ||
bm = 1; | ||
} | ||
|
||
var price, | ||
pubRev = (cpm * 1000) / bm, | ||
pubRevOrMaxTier = Math.min(pubRev, 10 * 2000); | ||
|
||
// round round cpms < .025 up to .05 | ||
if (pubRevOrMaxTier > 0 && pubRevOrMaxTier < 25) { | ||
pubRevOrMaxTier = 25; | ||
} | ||
|
||
if (pubRev < 1000) {// 5 cents to 1 dollar | ||
price = Math.round(pubRevOrMaxTier / 50) * 5; | ||
} else if (pubRev < 5000) {// 10 cents up to 5 dollar | ||
price = Math.round(pubRevOrMaxTier / 100) * 10; | ||
} else {// 50 cent up to max | ||
price = Math.round(pubRevOrMaxTier / 500) * 50; | ||
} | ||
return price + ""; | ||
} | ||
|
||
pbjs.bidderSettings = { | ||
openx: { | ||
alwaysUseBid: true, | ||
adserverTargeting: [ | ||
{ | ||
key: 'oxb', | ||
val: function(bidResponse) { | ||
return bidResponse.getSize() + '_' + _getBucketFromCPM(bidResponse.cpm); | ||
} | ||
} | ||
] | ||
} | ||
}; | ||
|
||
}); | ||
|
||
</script> | ||
|
||
<script type='text/javascript'> | ||
var slots = {}; | ||
googletag.cmd.push(function() { | ||
slots['slot1'] = googletag.defineSlot('/90577858/harman_bidid', [[728, 90]], 'div-gpt-ad-1394140255771-0').addService(googletag.pubads()); | ||
slots['slot1'].setTargeting('abc', 'yes'); | ||
|
||
pbjs.que.push(function() { | ||
pbjs.setTargetingForGPTAsync(); | ||
}); | ||
|
||
googletag.pubads().enableSingleRequest(); | ||
googletag.enableServices(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<h3>Slot 1</h3> | ||
<div id='div-gpt-ad-1394140255771-0' style='width:728px; height:90px;'> | ||
<script type='text/javascript'> | ||
googletag.cmd.push(function() { | ||
googletag.display('div-gpt-ad-1394140255771-0'); | ||
}); | ||
</script> | ||
</div> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.