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

Precisonat Bid Adapter : initial release #12208

Closed
wants to merge 10 commits into from
195 changes: 195 additions & 0 deletions integrationExamples/gpt/precisonativeExample.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<html>

<head>
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>

<script>
var PREBID_TIMEOUT = 2000;

var adUnits = [
{
code: 'test-div',
mediaTypes: {
native: {
adTemplate: `
<div class="sponsored-post">
<div class="thumbnail" style="background-image: url('${encodeURI('##hb_native_asset_id_3##')}'); width=100%; height=100%; background-repeat: no-repeat;
background-size: cover; >
<div class="content">
<h1>
<a href="${encodeURI("https://" + '##hb_native_linkurl##')}" target="_blank" class="pb-click" hb_native_asset_id="4" >
${encodeURI('##hb_native_body##')}
</a>
</h1>
<p class="pb-click">${encodeURI('##hb_native_asset_id_4##')}</p>
<div class="attribution" class="pb-click hb_native_asset_id="1">${encodeURI('##hb_native_asset_id_1##')}</div>
</div>
</div>
</div>
`,
ortb: {
assets: [
{
id: 3,
required: 1,
img: {
type: 3,
w: 300,
h: 250
}
},
{
id: 1,
required: 1,
title: {
len: 800
}
},
{
id: 4,
required: 0,
data: {
type: 1
}
}
]
}
}
},

bids: [
{
bidder: 'precisonat',
params: {
publisherId: 'PRECISO_TEST00001',
traffic: 'native',
bidFloor: 0.12,
currency: ['USD']
}
}
]
}
];

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
</script>



<script>
pbjs.que.push(function () {
pbjs.setConfig({ enableSendAllBids: true });
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
userSync: {
userIds: [{
name: 'sharedId',
storage: {
name: '_sharedid',
type: 'cookie',
expires: 365
}
}],
filterSettings: {
iframe: {
bidders: ['precisonat'],
filter: 'include'
},
image: {
bidders: ['preciso'],
filter: 'include'
}
}
},
floors: {
floorMin: 0.32,
currency: ['USD']
},
ortb2: {
bcat: ['IAB1-1'],
badv: ['example.com'],
wlang: ['fr', 'en']
},
enableTIDs: true,
debug: true
});
});

function renderEverything() {
var winners = pbjs.getHighestCpmBids();
for (var i = 0; i < winners.length; i++) {
renderOne(winners[i]);
}
}

function renderOne(winningBid) {
if (winningBid && winningBid.adId) {
let options = winningBid.adm
console.log("Here 123");
var div = document.getElementById(winningBid.adUnitCode);
if (div) {
let iframe = document.createElement('iframe');
iframe.frameBorder = '0';
iframe.style.width = '300';
iframe.style.height = '600';
div.appendChild(iframe);
console.log("Here 1234");
if (winningBid.mediaType == "native") {
console.log("Here 1234 native");
var domdoc = iframe.contentWindow.document;
console.log("Here 12345 native");
pbjs.renderAd(domdoc, winningBid.adId);
console.log("Here 123456 native");
}
}
}
}

</script>
<script>
pbjs.que.push(function () {
pbjs.requestBids({
timeout: 2000,

bidsBackHandler: renderEverything
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/native.js"></script>
<script>
var pbNativeTagData = {};
pbNativeTagData.pubUrl = '##hb_adomain##'; // GAM specific
pbNativeTagData.adId = "##hb_adid##"; // GAM specific
// if you're using 'Send All Bids' mode, you should use %%PATTERN:hb_adid_BIDDER%%
pbNativeTagData.requestAllAssets = true;
// if you want to track clicks in GAM, add the following variable
pbNativeTagData.clickUrlUnesc = "%%CLICK_URL_UNESC%%";
window.pbNativeTag.renderNativeAd(pbNativeTagData);
</script>
</head>

<body>
<h2>Ad Serverless Test Page</h2>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum
</p>
<div id="test-div"></div>
<p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin
literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney
College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and
going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum
comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by
Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance.
The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p>
<div id="test-nat-div"></div>
</body>

</html>
Loading