Skip to content

Commit

Permalink
Merge pull request #10 from harman-goei/update-examples
Browse files Browse the repository at this point in the history
feat(examples): APPS-11501: Update and cleanup examples for openx_neo
  • Loading branch information
Nandan Hirpathak committed May 16, 2016
2 parents b35c029 + 46369fa commit 67d423d
Show file tree
Hide file tree
Showing 13 changed files with 2,249 additions and 48 deletions.
88 changes: 55 additions & 33 deletions openxExamples/ox_creative.html → openxExamples/prebid_bypass.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<script>


var PREBID_TIMEOUT = 700;
var PREBID_TIMEOUT = 2500;

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
// googletag.cmd.push(function () {
// googletag.pubads().disableInitialLoad();
// });
// googletag.cmd.push(function () {
// googletag.pubads().disableInitialLoad();
// });

/* pbjs.initAdserver will be called either when all bids are back, or
when the timeout is reached.
Expand Down Expand Up @@ -50,33 +50,21 @@
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]],
code: 'div1',
sizes: [[468, 60]],
bids: [
{
bidder: 'openx',
bidder: 'openx_neo',
params: {
unit: '1611032360',
jstag_url: '//qa-v2-i63-auto-pmp.del-qa.openx.net/w/1.0/jstag?dbg=1&nc=90577858-harman_prebid'
unit: '1611012595',
delDomain: 'qa-v2-i35-presets.del-qa.openx.net'
}
}
]
}]);
}
]);

pbjs.requestBids({
bidsBackHandler: function() {
Expand Down Expand Up @@ -108,29 +96,46 @@
return price + "";
}


pbjs.bidderSettings = {
openx: {
alwaysUseBid: true,
standard: {
adserverTargeting: [
{
key: 'oxb',
val: function(bidResponse) {
return bidResponse.getSize() + '_' + _getBucketFromCPM(bidResponse.cpm);
key: "hb_bidder",
val: function (bidResponse) {
return bidResponse.bidderCode;
}
}, {
key: "hb_adid",
val: function (bidResponse) {
return bidResponse.adId;
}
}, {
key: "hb_pb",
val: function (bidResponse) {
return bidResponse.pbMg;
}
}
]
}
};


});

</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');
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
console.log('Slot has been rendered:');
console.log(event);
});

slots['slot1'] = googletag.defineSlot('/90577858/prebid_auid', [[468, 60]], 'div1').addService(googletag.pubads());
// slots['slot2'] = googletag.defineSlot('/90577858/prebid_auid', [[300, 250]], 'div2').addService(googletag.pubads());
// slots['slot3'] = googletag.defineSlot('/90577858/prebid_auid', [[160, 600]], 'div3').addService(googletag.pubads());

pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
Expand All @@ -139,18 +144,35 @@
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

function refresh(slots) {
pbjs.requestBids({
bidsBackHandler: function() {

googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
});
googletag.pubads().refresh(slots);
});
}
});
}

</script>
</head>
<body>

<button onclick="refresh()">Slot 1 Refresh</button>

<h3>Slot 1</h3>
<div id='div-gpt-ad-1394140255771-0' style='width:728px; height:90px;'>
<div id='div1' style='width:468px; height:60px;'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-1394140255771-0');
googletag.display('div1');
});
</script>
</div>

</body>
</html>
</html>
223 changes: 223 additions & 0 deletions openxExamples/prebid_delay_display_nosra.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>

<script>


var PREBID_TIMEOUT = 2500;

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);
})();

pbjs.que.push(function() {
pbjs.addAdUnits([{
code: 'div1',
sizes: [[728, 90]],
bids: [
{
bidder: 'openx_neo',
params: {
unit: '1611012595',
delDomain: 'qa-v2-i35-presets.del-qa.openx.net'
}
}
]
},
{
code: 'div2',
sizes: [[300, 250]],
bids: [
{
bidder: 'openx_neo',
params: {
unit: '1611012595',
delDomain: 'qa-v2-i35-presets.del-qa.openx.net'
}
}
]
},
{
code: 'div3',
sizes: [[160, 600]],
bids: [
{
bidder: 'openx_neo',
params: {
unit: '1611012595',
delDomain: 'qa-v2-i35-presets.del-qa.openx.net'
}
}
]
}]);

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 = {
standard: {
adserverTargeting: [
{
key: "hb_bidder",
val: function (bidResponse) {
return bidResponse.bidderCode;
}
}, {
key: "hb_adid",
val: function (bidResponse) {
return bidResponse.adId;
}
}, {
key: "hb_pb",
val: function (bidResponse) {
return bidResponse.pbMg;
}
}
]
}
};


});

</script>

<script type='text/javascript'>
var slots = {};
googletag.cmd.push(function() {
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
console.log('Slot has been rendered:');
console.log(event);
});

slots['slot1'] = googletag.defineSlot('/90577858/prebid_auid', [[728, 90]], 'div1').addService(googletag.pubads());
slots['slot2'] = googletag.defineSlot('/90577858/prebid_auid', [[300, 250]], 'div2').addService(googletag.pubads());
slots['slot3'] = googletag.defineSlot('/90577858/prebid_auid', [[160, 600]], 'div3').addService(googletag.pubads());

pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
});

//googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

function refresh(slots) {
pbjs.requestBids({
bidsBackHandler: function() {

googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
});
googletag.pubads().refresh(slots);
});
}
});
}

</script>
</head>
<body>

<button onclick="refresh()">Slot 1 Refresh</button>

<h3>Slot 1</h3>
<div id='div1' style='width:728px; height:90px;'>
<script type='text/javascript'>
setTimeout(function() {console.log('delay display');
googletag.cmd.push(function() {
googletag.display('div1');
});
},5000)
</script>
</div>

<h3>Slot 2</h3>
<div id='div2' style='width:300px; height:250px;'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div2');
});
</script>
</div>

<h3>Slot 3</h3>
<div id='div3' style='width:160px; height:600px;'>
<script type='text/javascript'>
googletag.cmd.push(function() {
googletag.display('div3');
});
</script>
</div>

</body>
</html>
Loading

0 comments on commit 67d423d

Please sign in to comment.