Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TPMN Bid Adapter: Change End-Point & Support Video #10611

Merged
merged 12 commits into from
Nov 13, 2023
168 changes: 168 additions & 0 deletions integrationExamples/gpt/tpmn_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Prebid.js Banner Example</title>
<!-- Prebid.js -->
<!-- <script async src="prebid.js"></script> -->
<script async src="../../build/dev/prebid.js"></script>
<!-- Google Publisher Tag -->
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script>
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
const customConfigObject = {
"buckets": [{
"max": 40,
"increment": 0.5
}]
};
// Prebid Banner Ad Unit
var adUnits = [
{
// Banner adUnit
code: 'banner-div-0',
mediaTypes: {
banner: {
sizes: [[300, 250]],
battr: []
}
},
bids: [{
bidder: 'tpmn',
params: {
inventoryId: 2,
bidFloor: 0.1,
}
}]
},
{
// Video adUnit
code: 'video-div-1',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480],
mimes: ['video/mp4'],
playbackmethod: [2, 4, 6],
api: [1, 2, 4, 6],
protocols: [3, 4, 7, 8, 10],
placement: 1,
minduration: 0,
maxduration: 60,
startdelay: 0,
skip: 1
},
},
bids: [{
bidder: 'tpmn',
params: {
inventoryId: 2,
bidFloor: 2.0,
}
}],
renderer: {
options: {
adText : "TPMN Ad",
disableCollapse : true
}
}
}
];
</script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});

pbjs.que.push(function () {
pbjs.setConfig({
debug: true,
enableSendAllBids: false,
priceGranularity: customConfigObject,
userSync: {
userIds: [{
name: "pubCommonId",
storage: {
name: "pubcid",
type: "cookie",
days: 30
}
},{
name: "unifiedId",
storage: {
type: "cookie",
name: "unifiedid",
expires: 60
}
}],
userIdAsEids: true
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdServerRequest });
});

function sendAdServerRequest() {
if (pbjs.adserverRequestSent) return;

//Google Ad Server Use Banner
googletag.cmd.push(() => {
googletag
.defineSlot('/19968336/header-bid-tag-0', [300, 250], 'banner-div-0')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});

//Direct Rendering Video
var highestCpmBids = pbjs.getHighestCpmBids('video-div-1');
console.log("highestCpmBids", highestCpmBids);
if (highestCpmBids.length) {
var doc = document.getElementById('video-div-1');
console.log("highestCpmBids[0].adId", highestCpmBids[0].adId);
pbjs.renderAd(doc, highestCpmBids[0].adId);
}

// googletag.cmd.push(() => {
// googletag
// .defineSlot('/19968336/header-bid-tag-0', [640, 480], 'video-div-1')
// .addService(googletag.pubads());
// googletag.pubads().enableSingleRequest();
// googletag.enableServices();
// });

googletag.cmd.push(function () {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync('banner-div-0');
pbjs.setTargetingForGPTAsync('video-div-1');
googletag.pubads().refresh();
});
});
}
</script>

</head>
<body>
<h2>Prebid.js TPMN Banner Example</h2>
<div id='banner-div-0'>
<script>
googletag.cmd.push(function () {
googletag.display('banner-div-0');
});
</script>
</div>
<br>
<h2>Prebid.js TPMN Video Example</h2>
<div id='video-div-1' style="width: 640px; height: 480px;">
<script>
googletag.cmd.push(function () {
googletag.display('video-div-1');
});
</script>
</div>
<br>
<div id="targeting-keys"></div>
</body>
121 changes: 121 additions & 0 deletions integrationExamples/gpt/tpmn_serverless_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!--
This page runs an auction for 2 adunits, simply displaying the results
rather than sending targeting to an ad server.

Notes:

- this approach assumes that the adunit.code is the div name. There
are many other ways to match the adunit to the div.
- this approach won't work for refreshed adunits. For that scenario
you'll need to be more surgical about what's passed into the bidsbackhandler.
- there's not a separate failsafe timeout here. Since there's no call to
an ad server waiting impatiently, Prebid's the only ad game in town and its
timeout is sufficient.
-->

<html>
<head>
<script>
var adUnits = [
{
// Banner adUnit
code: 'banner-div-0',
mediaTypes: {
banner: {
sizes: [[300, 250]],
battr: []
}
},
bids: [{
bidder: 'tpmn',
params: {
inventoryId: 2,
bidFloor: 0.1,
}
}]
},
{
// Video adUnit
code: 'video-div-1',
mediaTypes: {
video: {
context: 'outstream',
playerSize: [640, 480],
mimes: ['video/mp4'],
playbackmethod: [2, 4, 6],
api: [1, 2, 4, 6],
protocols: [3, 4, 7, 8, 10],
placement: 1,
minduration: 0,
maxduration: 60,
startdelay: 0,
skip: 1
},
},
bids: [{
bidder: 'tpmn',
params: {
inventoryId: 2,
bidFloor: 2.0,
}
}],
renderer: {
options: {
adText : "TPMN Ad",
disableCollapse : true
}
}
}
];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>
<script async src="../../build/dev/prebid.js"></script>

<script>
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
});

// you could instead pass an array of adUnits
// to getHighestCpmBids() if desired
function renderAllAdUnits() {
var winners=pbjs.getHighestCpmBids();
for (var i = 0; i < winners.length; i++) {
renderOne(winners[i]);
}
}

function renderOne(winningBid) {
if (winningBid && winningBid.adId) {
var div = document.getElementById(winningBid.adUnitCode);
if (div) {
let iframe = document.createElement('iframe');
iframe.frameBorder = '0';
div.appendChild(iframe);
var iframeDoc = iframe.contentWindow.document;
pbjs.renderAd(iframeDoc, winningBid.adId);
}
}
}
</script>

<script>
pbjs.que.push(function() {
pbjs.requestBids({
timeout: 2000,
bidsBackHandler: renderAllAdUnits
});
});
</script>
</head>

<body>
<h2>Ad Serverless Test Page</h2>

<div id='banner-div-0'></div>
<br/>
<div id='video-div-1' style="width: 640px; height: 480px;"></div>
</body>
</html>
Loading