forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptableRtdProvider_example.html
More file actions
341 lines (314 loc) · 11.8 KB
/
Copy pathoptableRtdProvider_example.html
File metadata and controls
341 lines (314 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html lang="en">
<head>
<title>Optable RTD submodule example - Prebid.js</title>
<!--Optable bundle-->
<script async src="https://prebidtest.solutions.cdn.optable.co/public-assets/prebidtest-sdk.js"></script>
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<script async src="../../build/dev/prebid.js"></script>
<meta charset="UTF-8">
<style>
body {
color: #222;
font-size: 1.5em;
line-height: 1.6;
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 0 0 32px;
}
.container {
max-width: 960px;
margin: 0 auto;
padding: 0 20px;
}
.delim {
margin: 27px 0 35px;
border-width: 0;
border-top: 1px solid #e1e1e1;
}
h1 {
font-size: 30px;
line-height: 1.35;
font-weight: 100;
letter-spacing: -0.5px;
}
h2 {
font-size: 24px;
line-height: 1.35;
font-weight: 100;
letter-spacing: -0.5px;
}
p {
font-size: 15px;
line-height: 24px;
font-weight: 400;
/*letter-spacing: -0.5px;*/
}
ul > li {
font-size: 15px;
line-height: 24px;
font-weight: 400;
/*letter-spacing: -0.5px;*/
}
a {
color: #1eaedb;
text-decoration: underline;
}
@media (min-width: 768px) {
.container {
padding: 0;
}
}
pre {
font-size: 13px;
max-width: 100%;
overflow-x: scroll;
padding: 16px;
background-color: #efefef;
border-radius: 6px;
}
</style>
<script>
var PREBID_TIMEOUT = 3000;
var FAILSAFE_TIMEOUT = 5000;
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
function initAdserver() {
if (pbjs.initAdserverSet) return;
googletag.cmd.push(function () {
if (pbjs.libLoaded) {
pbjs.que.push(function () {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
} else {
googletag.pubads().refresh();
}
});
pbjs.initAdserverSet = true;
}
pbjs.que.push(function () {
var adUnits = [
{
code: '/22081946781/web-sdk-demo-gam360/header-ad',
mediaTypes: {
banner: {
sizes: [[728, 90]],
},
},
bids: [{
bidder: 'pubmatic',
params: {
publisherId: "156209",
}
}]
},
{
code: '/22081946781/web-sdk-demo-gam360/box-ad',
mediaTypes: {
banner: {
sizes: [[250, 250], [300, 250], [200, 200]],
},
},
bids: [{
bidder: 'pubmatic',
params: {
publisherId: "156209",
}
}]
},
{
code: '/22081946781/web-sdk-demo-gam360/footer-ad',
mediaTypes: {
banner: {
sizes: [[728, 90]],
},
},
bids: [{
bidder: 'pubmatic',
params: {
publisherId: "156209",
}
}]
},
];
pbjs.setConfig({
debug: true, // use only for testing, remove in production
realTimeData: {
auctionDelay: 50,
dataProviders: [
{
name: 'optable',
waitForIt: true,
params: {
// adserverTargeting: false,
// handleRtd: async (reqBidsConfigObj, optableExtraData, mergeFn) => {
// const optableBundle = /** @type {Object} */ (window.optable);
// console.warn('Entering custom RTD handler');
// console.warn('reqBidsConfigObj', reqBidsConfigObj);
// console.warn('optableExtraData', optableExtraData);
// console.warn('mergeFn', mergeFn);
//
// // Call Optable DCN for targeting data and return the ORTB2 object
// const targetingData = await optableBundle.instance.targeting();
//
// if (!targetingData || !targetingData.ortb2) {
// return;
// }
//
// mergeFn(
// reqBidsConfigObj.ortb2Fragments.global,
// targetingData.ortb2,
// );
// }
}
}
]
},
});
pbjs.addAdUnits(adUnits);
pbjs.onEvent('bidRequested', function (data) {
try {
window.optable.cmd.push(() => {
document.getElementById('enriched-optable').style.display = 'block';
const jsonContent = JSON.stringify(data.ortb2.user, null, 2);
if (jsonContent) {
document.getElementById('enriched-optable-data').textContent = jsonContent;
}
});
} catch (e) {
console.error('Exception while trying to display enriched data', e);
}
});
pbjs.requestBids({
timeout: PREBID_TIMEOUT,
bidsBackHandler: function (bidResponses) {
initAdserver();
}
});
});
setTimeout(initAdserver, FAILSAFE_TIMEOUT);
</script>
<script>
googletag.cmd.push(function () {
googletag
.defineSlot(
'/22081946781/web-sdk-demo-gam360/header-ad',
[[728, 90]],
'div-gpt-ad-1598295788551-0'
)
.addService(googletag.pubads());
googletag
.defineSlot(
'/22081946781/web-sdk-demo-gam360/box-ad',
[[250, 250], [300, 250], [200, 200]],
'div-gpt-ad-1598295897480-0'
)
.addService(googletag.pubads());
googletag
.defineSlot(
'/22081946781/web-sdk-demo-gam360/footer-ad',
[[728, 90]],
'div-gpt-ad-1598296001655-0'
)
.addService(googletag.pubads());
googletag.pubads().disableInitialLoad();
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
</head>
<body>
<main class="container">
<div class="row">
<img
src="https://demo.optable.co/images/logo.png"
width="200"
alt="optable"
style="margin-top: 48px"/>
<hr class="delim" />
</div>
<div class="row">
<h1>Prebid.js Integration with OptableRTD</h1>
<h2>Overview</h2>
<p>
This demo demonstrates how to integrate Optable's targeting capabilities with Prebid.js using the
<a href="https://docs.prebid.org/dev-docs/modules/optableRtdProvider.html" target="_blank">OptableRTD module</a>.
The implementation assumes Google Ad Manager (GAM) as the primary ad server, integrated via
<a href="https://developers.google.com/publisher-tag/guides/get-started" target="_blank">Google Publisher Tag (GPT)</a>.
</p>
<h2>Key Features</h2>
<ul>
<li>Loads active visitor cohorts and passes them to Prebid.js via OptableRTD</li>
<li>Automatically forwards matching cohorts to GAM for targeting</li>
<li>Supports local cache updates for improved targeting accuracy</li>
<li>Configurable GAM targeting override via localStorage</li>
</ul>
<h2>Implementation</h2>
<p>
The Prebid.js configuration requires minimal setup. Here's the essential configuration:
</p>
<pre><code>pbjs.mergeConfig({
debug: true, // use only for testing, remove in production
priceGranularity: "low",
userSync: {
iframeEnabled: true,
enabledBidders: ["pubmatic"]
},
realTimeData: {
auctionDelay: 50,
dataProviders: [{
name: 'optable',
waitForIt: true // Required to respect auctionDelay
}]
}
});</code></pre>
<h2>Important Notes</h2>
<ul>
<li>
<strong>Targeting Cache:</strong> For optimal targeting accuracy, call <code>targeting</code>
on page load to update the local cache, as the RTD module only uses cached values.
</li>
<li>
<strong>GAM Targeting Override:</strong> Set <code>localStorage.disableGamTargeting = "true"</code>
before page load to prevent the SDK from sending targeting data to GAM.
</li>
</ul>
</div>
<h2>web-sdk-demo-gam360/header-ad</h2>
<div id="div-gpt-ad-1598295788551-0">
<p>No response</p>
<script type="text/javascript">
googletag.cmd.push(function () {
googletag.display('div-gpt-ad-1598295788551-0');
});
</script>
</div>
<h2>web-sdk-demo-gam360/box-ad</h2>
<div id="div-gpt-ad-1598295897480-0">
<p>No response</p>
<script type="text/javascript">
googletag.cmd.push(function () {
googletag.display('div-gpt-ad-1598295897480-0');
});
</script>
</div>
<h2>web-sdk-demo-gam360/footer-ad</h2>
<div id="div-gpt-ad-1598296001655-0">
<p>No response</p>
<script type="text/javascript">
googletag.cmd.push(function () {
googletag.display('div-gpt-ad-1598296001655-0');
});
</script>
</div>
<div id="enriched-optable" style="display: none;">
<h2>Enriched ortb2.user data from Optable RTD module</h2>
<pre id="enriched-optable-data">(this demo doesn't block the auction, so the data will be empty until the new auction is triggered)
(refresh the page)</pre>
</div>
</main>
</body>
</html>