Skip to content

Commit 0f7c725

Browse files
zapoBohdanVVjustadreamer
authored
New RTD submodule: optableRtdProvider (#12850)
* Optable RTD submodule: Initial commit * fix typo: user.ext.data -> user.data * Optable RTD submodule: Restrict insecure bundle URLs * optableRtdProvider doc: add a note to erase optable.ext. custom fields * Optable RTD submodule: Change the method of passing extra data --------- Co-authored-by: Bohdan V <[email protected]> Co-authored-by: Eugene Dorfman <[email protected]>
1 parent 7ea5fe8 commit 0f7c725

File tree

6 files changed

+851
-0
lines changed

6 files changed

+851
-0
lines changed
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Optable RTD submodule example - Prebid.js</title>
5+
<!--Optable bundle-->
6+
<script async src="https://prebidtest.solutions.cdn.optable.co/public-assets/prebidtest-sdk.js"></script>
7+
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
8+
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
9+
<script async src="../../build/dev/prebid.js"></script>
10+
<meta charset="UTF-8">
11+
<style>
12+
body {
13+
color: #222;
14+
font-size: 1.5em;
15+
line-height: 1.6;
16+
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
17+
margin: 0;
18+
}
19+
20+
.container {
21+
max-width: 960px;
22+
margin: 0 auto;
23+
padding: 0 20px;
24+
}
25+
26+
.delim {
27+
margin: 27px 0 35px;
28+
border-width: 0;
29+
border-top: 1px solid #e1e1e1;
30+
}
31+
32+
h1 {
33+
font-size: 30px;
34+
line-height: 1.35;
35+
font-weight: 100;
36+
letter-spacing: -0.5px;
37+
}
38+
39+
a {
40+
color: #1eaedb;
41+
text-decoration: underline;
42+
}
43+
44+
@media (min-width: 768px) {
45+
.container {
46+
padding: 0;
47+
}
48+
}
49+
50+
#enriched-optable-data {
51+
font-size: 12px;
52+
max-width: 100%;
53+
overflow-x: scroll;
54+
padding: 16px;
55+
background-color: #efefef;
56+
border-radius: 6px;
57+
}
58+
</style>
59+
<script>
60+
var PREBID_TIMEOUT = 3000;
61+
var FAILSAFE_TIMEOUT = 5000;
62+
63+
var googletag = googletag || {};
64+
googletag.cmd = googletag.cmd || [];
65+
66+
var pbjs = pbjs || {};
67+
pbjs.que = pbjs.que || [];
68+
69+
function initAdserver() {
70+
if (pbjs.initAdserverSet) return;
71+
72+
googletag.cmd.push(function () {
73+
pbjs.que.push(function () {
74+
pbjs.setTargetingForGPTAsync();
75+
googletag.pubads().refresh();
76+
});
77+
});
78+
79+
pbjs.initAdserverSet = true;
80+
}
81+
82+
pbjs.que.push(function () {
83+
var adUnits = [
84+
{
85+
code: '/22081946781/web-sdk-demo-gam360/header-ad',
86+
mediaTypes: {
87+
banner: {
88+
sizes: [[728, 90]],
89+
},
90+
},
91+
bids: [{
92+
bidder: 'appnexus',
93+
params: {
94+
placementId: 13232392,
95+
}
96+
}]
97+
},
98+
{
99+
code: '/22081946781/web-sdk-demo-gam360/box-ad',
100+
mediaTypes: {
101+
banner: {
102+
sizes: [[250, 250], [300, 250], [200, 200]],
103+
},
104+
},
105+
bids: [{
106+
bidder: 'appnexus',
107+
params: {
108+
placementId: 13232392,
109+
}
110+
}]
111+
},
112+
{
113+
code: '/22081946781/web-sdk-demo-gam360/footer-ad',
114+
mediaTypes: {
115+
banner: {
116+
sizes: [[728, 90]],
117+
},
118+
},
119+
bids: [{
120+
bidder: 'appnexus',
121+
params: {
122+
placementId: 13232392,
123+
}
124+
}]
125+
},
126+
];
127+
128+
pbjs.setConfig({
129+
optableRtdConfig: { // optional, check the doc for explanation
130+
email: 'email-sha256-hash',
131+
phone: 'phone-sha256-hash',
132+
postal_code: 'postal_code',
133+
},
134+
debug: true, // use only for testing, remove in production
135+
realTimeData: {
136+
auctionDelay: 1000, // should be set lower in production use
137+
dataProviders: [
138+
{
139+
name: 'optable',
140+
waitForIt: true,
141+
params: {
142+
// bundleUrl: "https://prebidtest.solutions.cdn.optable.co/public-assets/prebidtest-sdk.js?hello=world",
143+
// adserverTargeting: false,
144+
// handleRtd: async (reqBidsConfigObj, optableExtraData, mergeFn) => {
145+
// const optableBundle = /** @type {Object} */ (window.optable);
146+
// console.warn('Entering custom RTD handler');
147+
// console.warn('reqBidsConfigObj', reqBidsConfigObj);
148+
// console.warn('optableExtraData', optableExtraData);
149+
// console.warn('mergeFn', mergeFn);
150+
//
151+
// // Call Optable DCN for targeting data and return the ORTB2 object
152+
// const targetingData = await optableBundle.instance.targeting();
153+
//
154+
// if (!targetingData || !targetingData.ortb2) {
155+
// return;
156+
// }
157+
//
158+
// mergeFn(
159+
// reqBidsConfigObj.ortb2Fragments.global,
160+
// targetingData.ortb2,
161+
// );
162+
// }
163+
}
164+
}
165+
]
166+
},
167+
});
168+
169+
pbjs.addAdUnits(adUnits);
170+
171+
pbjs.onEvent('bidRequested', function (data) {
172+
try {
173+
window.optable.cmd.push(() => {
174+
document.getElementById('enriched-optable').style.display = 'block';
175+
document.getElementById('enriched-optable-data').textContent = JSON.stringify(data.ortb2.user, null, 2);
176+
});
177+
} catch (e) {
178+
console.error('Exception while trying to display enriched data', e);
179+
}
180+
});
181+
182+
pbjs.requestBids({
183+
timeout: PREBID_TIMEOUT,
184+
bidsBackHandler: function (bidResponses) {
185+
initAdserver();
186+
}
187+
});
188+
});
189+
setTimeout(initAdserver, FAILSAFE_TIMEOUT);
190+
</script>
191+
192+
<script>
193+
googletag.cmd.push(function () {
194+
googletag
195+
.defineSlot(
196+
'/22081946781/web-sdk-demo-gam360/header-ad',
197+
[[728, 90]],
198+
'div-gpt-ad-1598295788551-0'
199+
)
200+
.addService(googletag.pubads());
201+
202+
googletag
203+
.defineSlot(
204+
'/22081946781/web-sdk-demo-gam360/box-ad',
205+
[[250, 250], [300, 250], [200, 200]],
206+
'div-gpt-ad-1598295897480-0'
207+
)
208+
.addService(googletag.pubads());
209+
210+
googletag
211+
.defineSlot(
212+
'/22081946781/web-sdk-demo-gam360/footer-ad',
213+
[[728, 90]],
214+
'div-gpt-ad-1598296001655-0'
215+
)
216+
.addService(googletag.pubads());
217+
218+
googletag.pubads().disableInitialLoad();
219+
googletag.pubads().enableSingleRequest();
220+
googletag.enableServices();
221+
});
222+
</script>
223+
</head>
224+
<body>
225+
<main class="container">
226+
<div class="row">
227+
<img
228+
src="https://demo.optable.co/images/logo.png"
229+
width="200"
230+
alt="optable"
231+
style="margin-top: 48px"/>
232+
<hr class="delim" />
233+
</div>
234+
<div class="row">
235+
<h1>Optable RTD module example</h1>
236+
</div>
237+
238+
<h3>web-sdk-demo-gam360/header-ad</h3>
239+
<div id="div-gpt-ad-1598295788551-0">
240+
<p>No response</p>
241+
<script type="text/javascript">
242+
googletag.cmd.push(function () {
243+
googletag.display('div-gpt-ad-1598295788551-0');
244+
});
245+
</script>
246+
</div>
247+
248+
<h3>web-sdk-demo-gam360/box-ad</h3>
249+
<div id="div-gpt-ad-1598295897480-0">
250+
<p>No response</p>
251+
<script type="text/javascript">
252+
googletag.cmd.push(function () {
253+
googletag.display('div-gpt-ad-1598295897480-0');
254+
});
255+
</script>
256+
</div>
257+
258+
<h3>web-sdk-demo-gam360/footer-ad</h3>
259+
<div id="div-gpt-ad-1598296001655-0">
260+
<p>No response</p>
261+
<script type="text/javascript">
262+
googletag.cmd.push(function () {
263+
googletag.display('div-gpt-ad-1598296001655-0');
264+
});
265+
</script>
266+
</div>
267+
268+
<div id="enriched-optable" style="display: none;">
269+
<h3>Enriched ortb2.user data from Optable RTD module</h3>
270+
<pre id="enriched-optable-data"></pre>
271+
</div>
272+
</main>
273+
</body>
274+
</html>

modules/.submodules.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"mobianRtdProvider",
9898
"neuwoRtdProvider",
9999
"oneKeyRtdProvider",
100+
"optableRtdProvider",
100101
"optimeraRtdProvider",
101102
"oxxionRtdProvider",
102103
"permutiveRtdProvider",

0 commit comments

Comments
 (0)