Skip to content

Commit

Permalink
Merge pull request #1 from harman-goei/openx
Browse files Browse the repository at this point in the history
fix(prebid,arj): APPS-11501: Add Openx_Neo Adapter that utilizes ARJs
  • Loading branch information
Harman Goei committed May 11, 2016
2 parents 1e0fde4 + f5e7ce7 commit 62e3d65
Show file tree
Hide file tree
Showing 7 changed files with 1,176 additions and 27 deletions.
27 changes: 0 additions & 27 deletions integrationExamples/gpt/pbjs_example_gpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -393,31 +393,4 @@ <h2>Prebid.js Test</h2>


</body>

<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'XXXXXX', 'auto');
//Send data from prebid.js automatically
pbjs.que.push(function () {
pbjs.enableAnalytics({
provider: 'ga',
options: {
global: 'ga', // <string> name of GA global. Default is 'ga'
enableDistribution: false, // <bool> enable/disable distribution. Recommend disable to save bandwidth/calls
}
});
});
</script>

</html>
156 changes: 156 additions & 0 deletions openxExamples/ox_creative.html
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>
Loading

0 comments on commit 62e3d65

Please sign in to comment.