-
Notifications
You must be signed in to change notification settings - Fork 2
/
getting-started.html
executable file
·452 lines (435 loc) · 14.5 KB
/
getting-started.html
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="Header Bidding, Framework, HeaderBidding, Pubfood">
<title>Getting Started | Pubfood</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
<style>
.content ul ul {
list-style: none;
}
#section-ip-2 li {
background-image: none;
margin: 0;
}
#div-rail {
font-family: monospace;
}
#div-rail h3 {
font-size: 15px;
font-weight: bold;
}
#div-rail h4 {
font-size: 13px;
font-weight: bold;
}
#div-rail p {
margin: 0;
}
.loose li {
height:4em;
}
.loose span.code-ref {
margin-left: 60px;
}
#theAd {
margin: 0 0 60px 60px;
}
</style>
<script src="pubfood.min.js"></script>
<script>
// global for the auction provider
window.googletag = window.googletag || {};
googletag.cmd = googletag.cmd || [];
// globals for all bid providers
window.yieldbot = window.yieldbot || {};
yieldbot.cmd = yieldbot.cmd || [];
var pf = new pubfood();
pf.addSlot({
name: '18752725/leaderboard_slot',
elementId: 'div-gpt-ad-5119317744421-0',
sizes: [[300, 250]],
bidProviders: ['yieldbot']
});
pf.addBidProvider({
name: 'yieldbot',
libUri: 'http://cdn.yldbt.com/js/yieldbot.intent.js',
init: function(slots, pushBid, done) {
window.googletag = window.googletag || {};
googletag.cmd = googletag.cmd || [];
var ybotq = ybotq || [];
ybotq.push(function() {
yieldbot.psn('0000');
for (var k = 0; k < slots.length; k++) {
var slot = slots[k];
yieldbot.defineSlot(slot.getParam('yieldbot').slot, {
sizes: slot.sizes
});
}
yieldbot.enableAsync();
yieldbot.go();
});
ybotq.push(function() {
var criteria = yieldbot.getPageCriteria(); // e.g. medrec:300x250:300
if (criteria) {
pushBid({
targeting: {
ybot: criteria
}
});
}
done();
});
},
refresh: function(slots, pushBid, done) {
}
});
pf.setAuctionProvider({
name: 'Google',
libUri: 'http://www.googletagservices.com/tag/js/gpt.js',
init: function(targeting, done) {
googletag.cmd.push(function() {
for (var i = 0; i < targeting.length; i++) {
var tgtObject = targeting[i];
var gptObject;
if (tgtObject.name) {
gptObject = googletag.defineSlot(tgtObject.name, tgtObject.sizes, tgtObject.elementId)
.addService(googletag.pubads());
} else {
gptObject = googletag.pubads();
}
for (var p in tgtObject.targeting) {
gptObject.setTargeting(p, tgtObject.targeting[p]);
}
}
});
googletag.cmd.push(function() {
googletag.pubads().enableSingleRequest();
googletag.enableServices();
done();
});
},
refresh: function(targeting, done) {
done();
}
});
pf.timeout(1500);
pf.observe(function(ev) {
console.log(ev);
});
pf.start();
</script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- begin header -->
<div class="top-wrapper-outer">
<div id="top-wrapper">
<div class="top-w-1">
<div id="logo"><a href="/"><img src="images/logo.png" width="162" height="142" title="Pubfood" alt="Pubfood logo"></a></div>
</div><!-- end .top-w-1 -->
<div class="top-w-2">
<div id="main-nav">
<ul>
<li><a class="mn-link-active" href="/getting-started">Getting Started</a></li>
<li><a href="/why-pubfood">Why Pubfood</a></li>
<li><a href="/analytics">Pubfood Analytics</a></li>
<li><a href="/api-reference">API Reference</a></li>
<li><a href="/testimonials">Testimonials</a></li>
<li><a href="/integration-playbook">Ad Ops Guide</a></li>
<li><a href="https://github.com/pubfood/pubfood" target="_blank">GitHub</a></li>
<li><a href="mailto:[email protected]?subject=Invite%20Request:%20Pubfood.js%20Slack%20Channel">Contact</a></li>
</ul>
</div><!-- end #main-nav -->
</div><!-- end .top-w-2 -->
<div class="clear-float"></div>
<div id="mn-toggle-link"><a href="javascript:void(0)" title="show main navigation"></a></div>
</div><!-- end #top-wrapper -->
</div><!-- end .top-wrapper-outer -->
<!-- end header -->
<div id="section-ip-1" class="content">
<!-- begin section connector :: needed to complete header -->
<div class="section-connector-1"><img src="images/half-circle-1.png" width="120" height="35" alt="half circle" /></div>
<!-- end section connector :: needed to complete header -->
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-md-8">
</div>
</div><!-- end .row -->
</div><!-- end .container-fluid -->
</div><!-- end #section-ip-1 -->
<div id="section-ip-2" class="content">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12" >
<h2>Quick Start<!-- br><small> Implementing Header Bidding</small> --></h2>
<br />
</div>
</div>
<div class="row">
<div class="col-xs-12">
<h4>1. Load the Pubfood library</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="step">
<!-- <div class="step-text">To execute the following steps in your own code, you will need to include the Pubfood JavaScript library.</div> -->
<div class="code-sample">
<b><a href="https://github.com/pubfood/pubfood/tree/master/dist">https://github.com/pubfood/pubfood/tree/master/dist</a></b>
<pre id="step0-code" class="prettyprint linenums"><script src="/pubfood.min.js"></script>
<script>/* Or, inline pubfood.min.js in your code */</script></pre>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 1</span> - Load Pubfood</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<h4>2. Define slots and determine which bid providers will bid on them</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="code-sample">
<pre id="step1-code" class="prettyprint linenums">var pf = new pubfood();
pf.addSlot({
name: '18752725/leaderboard_slot',
elementId: 'div-gpt-ad-5119317744421-0',
sizes: [[300, 250]],
bidProviders: ['yieldbot']
});</pre>
</div> <!-- CODE SAMPLE -->
</div> <!-- END OF COL -->
<div class="col-xs-12 col-sm-6 col-md-4">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 3</span> - DFP slot name</li>
<li><span class="lines-ref">Line 4</span> - id of the element serving the ad</li>
<li><span class="lines-ref">Line 5</span> - All sizes of the slot</li>
<li><span class="lines-ref">Line 6</span> - Bidders you want to serve on this unit</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<h4>3. Declare each header bidder you want to integrate into pubfood</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="code-sample">
<pre id="step2-code" class="prettyprint linenums">pf.addBidProvider({
name: 'yieldbot',
libUri: 'http://cdn.yldbt.com/js/yieldbot.intent.js',
init: function(slots, pushBid, done) {
ybotq.push(function() {
yieldbot.psn('0000');
for (var k = 0; k < slots.length; k++) {
var slot = slots[k];
yieldbot.defineSlot(slot.getParam('yieldbot').slot, {
sizes: slot.sizes
});
}
yieldbot.enableAsync();
yieldbot.go();
});
ybotq.push(function() {
var criteria = yieldbot.getPageCriteria(); // e.g. medrec:300x250:300
if (criteria) {
pushBid({
targeting: {
ybot: criteria
}
});
}
done();
});
},
refresh: function(slots, pushBid, done) {
}
});</pre>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="step-text">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 2</span> - Bidder name</li>
<li><span class="lines-ref">Line 3</span> - Bid provider JavaScript library</li>
<li><span class="lines-ref">Line 4</span> - Function to initialize bids</li>
<li><span class="lines-ref">Line 15</span> - Submit a bid with the <span class="code-ref">pushBid({});</span> callback</li>
<li><span class="lines-ref">Line 24</span> - Notify Pubfood.js with the <span class="code-ref">done();</span> callback</li>
<li><span class="lines-ref">Line 27</span> - Function to refresh bids</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<h4>4. Declare DFP</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="code-sample">
<pre id="step3-code" class="prettyprint lang-js linenums">pf.setAuctionProvider({
name: 'Google',
libUri: 'http://www.googletagservices.com/tag/js/gpt.js',
init: function(targeting, done) {
googletag.cmd.push(function() {
for (var i = 0; i < targeting.length; i++) {
var tgtObject = targeting[i];
var gptObject;
if (tgtObject.name) {
gptObject = googletag.defineSlot(tgtObject.name, tgtObject.sizes, tgtObject.elementId)
.addService(googletag.pubads());
} else {
gptObject = googletag.pubads();
}
for (var p in tgtObject.targeting) {
gptObject.setTargeting(p, tgtObject.targeting[p]);
}
}
});
googletag.cmd.push(function() {
googletag.pubads().enableSingleRequest();
googletag.enableServices();
done();
});
},
refresh: function(targeting, done) {
done();
}
});</pre>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="step-text">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 2</span> - The auction provider name</li>
<li><span class="lines-ref">Line 3</span> - The auction provider JavaScript library</li>
<li><span class="lines-ref">Line 4</span> - The function to initialize the auction</li>
<li><span class="lines-ref">Line 23</span> - Notify Pubfood.js with the <span class="code-ref">done();</span> callback</li>
<li><span class="lines-ref">Line 26</span> - The function to refresh with a new auction</li>
<li><span class="lines-ref">Note: </span> Pubfood also supports other ad servers.</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<h4>5. Start the auction</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="code-sample">
<pre id="step4-code" class="prettyprint lang-js linenums">pf.timeout(1500);
pf.observe(function(ev) {
console.log(ev);
});
pf.start();</pre>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="step-text">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 1</span> - Bidders need to respond within this time</li>
<li><span class="lines-ref">Line 2</span> - Observe all events for debugging</li>
<li><span class="lines-ref">Line 5</span> - Start the auction</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<h4>6. Declare where you will display ads</h4>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">
<div class="code-sample">
<pre id="step5-code" class="prettyprint lang-js linenums">pf.observe('AUCTION_POST_RUN', function() {
googletag.cmd.push(function() {
googletag.display('div-gpt-ad-5119317744421-0');
});
});</pre>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="step-text">
<ul class="getting-started-list">
<li><span class="lines-ref">Line 1</span> - Observe the auction provider</li>
<li><span class="lines-ref">Line 3</span> - The auction provider will display the ad</li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<br />
<p>
<span style="font-size: larger; font-weight: bold">Nicely done.</span>
You completed this quick tutorial.<br/>
See the <a href="/api-reference">API REFERENCE</a> for more.
</p>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sons-of-obsidian"></script>
</div>
</div>
</div><!-- end .container-fluid -->
</div><!-- end #section-ip-2 -->
<!-- begin footer -->
<div class="footer-wrapper-outer">
<div id="footer-wrapper">
<div id="footer-logo">
<img class="f-logo-1" src="images/logo.png" width="162" height="142" alt="Pubfood logo" />
<img class="f-logo-2" src="images/logo-2.png" width="100" height="88" alt="Pubfood logo - smaller size" />
</div>
<ul>
<li><a href="https://github.com/pubfood/pubfood" target="_blank">GitHub</a></li>
<!-- <li><a href="#">Contact</a></li> -->
<li><a href="mailto:[email protected]?subject=Invite%20Request%3A%20Pubfood.js%20Slack%20Channel">Join the Pubfood.js Slack</a></li>
<li><a href="https://twitter.com/yieldbot" target="_blank"><img src="images/icon-twitter.png" width="28" height="24" alt="Twitter" /></a></li>
</ul>
<p><span>©
<script type="text/javascript">
(function display_the_cr_year() {
var the_cr_date = new Date();
var the_cr_current_year = the_cr_date.getFullYear();
document.write(the_cr_current_year);
})();
</script>
Pubfood.js</span> <span>All Rights Reserved</span></p>
</div><!-- end #footer-wrapper -->
</div><!-- end .footer-wrapper-outer -->
<!-- end footer -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<!-- begin Google Analytics code -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69476533-1', 'pubfood.org');
ga('send', 'pageview');
</script>
<!-- end Google Analytics code -->
</body>
</html>