|
1 | | -<!-- |
2 | | - This page calls a single bidder for a single ad slot. It can be considered a "hello world" example for using |
3 | | - Prebid with the Google Publisher Tag. |
4 | | - It also makes a good test page for new adapter PR submissions. Simply set your server's Bid Params object in the |
5 | | - bids array inside the adUnits, and it will use your adapter to load an ad. |
6 | | - NOTE that many ad servers won't send back an ad if the URL is localhost... so you might need to |
7 | | - set an alias in your /etc/hosts file so that you can load this page from a different domain. |
8 | | ---> |
9 | | - |
10 | | -<html> |
11 | | - |
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
12 | 3 | <head> |
13 | | - <script src="./prebid-n2.js"></script> |
14 | | - <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> |
15 | | - <script> |
16 | | - var FAILSAFE_TIMEOUT = 5300; |
17 | | - var PREBID_TIMEOUT = 3000; |
18 | | - |
19 | | - var adUnits = [{ |
20 | | - code: 'div-gpt-ad-1460505748561-0', |
21 | | - mediaTypes: { |
22 | | - banner: { |
23 | | - sizes: [[300, 250]], |
24 | | - } |
25 | | - }, |
26 | | - |
27 | | - // Replace this object to test a new Adapter! |
28 | | - bids: [{ |
29 | | - bidder: 'mediafuse', |
30 | | - params: { |
31 | | - placementId: 37151837 |
32 | | - } |
33 | | -}] |
34 | | - |
35 | | - }]; |
36 | | - |
37 | | - var pbjs = pbjs || {}; |
38 | | - pbjs.que = pbjs.que || []; |
39 | | - |
40 | | - </script> |
41 | | - |
42 | | - <script> |
43 | | - var googletag = googletag || {}; |
44 | | - googletag.cmd = googletag.cmd || []; |
45 | | - googletag.cmd.push(function () { |
46 | | - googletag.pubads().disableInitialLoad(); |
47 | | - }); |
48 | | - |
49 | | - pbjs.que.push(function () { |
50 | | - pbjs.addAdUnits(adUnits); |
51 | | - |
52 | | - pbjs.requestBids({ |
53 | | - bidsBackHandler: sendAdserverRequest, |
54 | | - timeout: PREBID_TIMEOUT |
55 | | - }); |
56 | | - }); |
57 | | - |
58 | | - function sendAdserverRequest() { |
59 | | - if (pbjs.adserverRequestSent) return; |
60 | | - pbjs.adserverRequestSent = true; |
61 | | - googletag.cmd.push(function () { |
62 | | - if (pbjs.libLoaded) { |
63 | | - pbjs.que.push(function () { |
64 | | - pbjs.setTargetingForGPTAsync(); |
65 | | - googletag.pubads().refresh(); |
66 | | - }); |
67 | | - } else { |
68 | | - googletag.pubads().refresh(); |
69 | | - } |
70 | | - }); |
71 | | - } |
72 | | - |
73 | | - setTimeout(function () { |
74 | | - sendAdserverRequest(); |
75 | | - }, FAILSAFE_TIMEOUT); |
76 | | - |
77 | | - </script> |
78 | | - |
79 | | - <script> |
80 | | - googletag.cmd.push(function () { |
81 | | - googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads()); |
82 | | - |
83 | | - googletag.pubads().enableSingleRequest(); |
84 | | - googletag.enableServices(); |
85 | | - }); |
86 | | - </script> |
| 4 | +<meta charset="UTF-8" /> |
| 5 | +<title>Mediafuse Prebid Multi-Format Test</title> |
| 6 | +<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 7 | + |
| 8 | +<style> |
| 9 | +body { |
| 10 | +font-family: Arial, sans-serif; |
| 11 | +padding: 40px; |
| 12 | +background: #f5f5f5; |
| 13 | +} |
| 14 | + |
| 15 | +h2 { margin-top: 40px; } |
| 16 | + |
| 17 | +.slot { |
| 18 | +border: 2px dashed #999; |
| 19 | +background: #fff; |
| 20 | +padding: 10px; |
| 21 | +margin-bottom: 30px; |
| 22 | +} |
| 23 | + |
| 24 | +#banner { width: 300px; height: 250px; } |
| 25 | +#video { width: 640px; height: 360px; } |
| 26 | +#native { width: 300px; } |
| 27 | + |
| 28 | +.error { border-color: #d32f2f; color: #d32f2f; } |
| 29 | +</style> |
87 | 30 | </head> |
88 | 31 |
|
89 | 32 | <body> |
90 | | - <h2>Prebid.js Test</h2> |
91 | | - <h5>Div-1</h5> |
92 | | - <div id='div-gpt-ad-1460505748561-0'> |
93 | | - <script type='text/javascript'> |
94 | | - googletag.cmd.push(function () { googletag.display('div-gpt-ad-1460505748561-0'); }); |
95 | | - </script> |
96 | | - </div> |
97 | | -</body> |
98 | 33 |
|
99 | | -</html> |
| 34 | +<h1>Mediafuse Prebid Multi-Format Test</h1> |
| 35 | + |
| 36 | +<!-- ================= BANNER ================= --> |
| 37 | +<h2>Banner Test (37151836 / 37151837)</h2> |
| 38 | +<div id="banner" class="slot">Requesting banner bid…</div> |
| 39 | + |
| 40 | +<!-- ================= VIDEO ================= --> |
| 41 | +<h2>Video Test (37151841 / 37151839 / 37151840)</h2> |
| 42 | +<div id="video" class="slot">Requesting video bid…</div> |
| 43 | + |
| 44 | +<!-- ================= NATIVE ================= --> |
| 45 | +<h2>Native Test (37151838)</h2> |
| 46 | +<div id="native" class="slot">Requesting native bid…</div> |
| 47 | + |
| 48 | +<script src="./prebid-n3.js"></script> |
100 | 49 |
|
| 50 | +<script> |
| 51 | +var pbjs = pbjs || {}; |
| 52 | +pbjs.que = pbjs.que || []; |
| 53 | + |
| 54 | +pbjs.que.push(function () { |
| 55 | + |
| 56 | +console.log("Prebid version:", pbjs.version); |
| 57 | + |
| 58 | +pbjs.addAdUnits([ |
| 59 | +/* ================= BANNER ================= */ |
| 60 | +{ |
| 61 | +code: 'banner', |
| 62 | +mediaTypes: { |
| 63 | +banner: { sizes: [[300, 250], [300, 50]] } |
| 64 | +}, |
| 65 | +bids: [{ |
| 66 | +bidder: 'mediafuse', |
| 67 | +params: { placementId: '37151837' } |
| 68 | +}] |
| 69 | +}, |
| 70 | + |
| 71 | +/* ================= VIDEO ================= */ |
| 72 | +{ |
| 73 | +code: 'video', |
| 74 | +mediaTypes: { |
| 75 | +video: { |
| 76 | +context: 'instream', |
| 77 | +playerSize: [640, 360], |
| 78 | +mimes: ['video/mp4'], |
| 79 | +protocols: [2,3,5,6], |
| 80 | +api: [2], |
| 81 | +playbackmethod: [1] |
| 82 | +} |
| 83 | +}, |
| 84 | +bids: [{ |
| 85 | +bidder: 'mediafuse', |
| 86 | +params: { placementId: '37151841' } |
| 87 | +}] |
| 88 | +}, |
| 89 | + |
| 90 | +/* ================= NATIVE ================= */ |
| 91 | +{ |
| 92 | +code: 'native', |
| 93 | +mediaTypes: { |
| 94 | +native: { |
| 95 | +title: { required: true, len: 80 }, |
| 96 | +image: { required: true, sizes: [150, 150] }, |
| 97 | +sponsoredBy: { required: true } |
| 98 | +} |
| 99 | +}, |
| 100 | +bids: [{ |
| 101 | +bidder: 'mediafuse', |
| 102 | +params: { placementId: '37151838' } |
| 103 | +}] |
| 104 | +} |
| 105 | +]); |
| 106 | + |
| 107 | +pbjs.requestBids({ |
| 108 | +timeout: 3000, |
| 109 | +bidsBackHandler: renderAds |
| 110 | +}); |
| 111 | + |
| 112 | +}); |
| 113 | + |
| 114 | +function renderAds() { |
| 115 | + |
| 116 | +/* ================= BANNER RENDER ================= */ |
| 117 | +var bannerResp = pbjs.getBidResponsesForAdUnitCode('banner'); |
| 118 | +if (bannerResp && bannerResp.bids.length) { |
| 119 | +var bid = bannerResp.bids[0]; |
| 120 | +document.getElementById('banner').innerHTML = bid.ad || bid.adm; |
| 121 | +} else { |
| 122 | +document.getElementById('banner').innerHTML = "No banner bid"; |
| 123 | +document.getElementById('banner').className += " error"; |
| 124 | +} |
| 125 | + |
| 126 | +/* ================= VIDEO RENDER ================= */ |
| 127 | +var videoResp = pbjs.getBidResponsesForAdUnitCode('video'); |
| 128 | +if (videoResp && videoResp.bids.length) { |
| 129 | +var bid = videoResp.bids[0]; |
| 130 | + |
| 131 | +if (bid.vastXml) { |
| 132 | +document.getElementById('video').innerHTML = |
| 133 | +"<pre style='font-size:10px;overflow:auto'>" + |
| 134 | +bid.vastXml.replace(/</g,"<") + |
| 135 | +"</pre>"; |
| 136 | +} else if (bid.vastUrl) { |
| 137 | +document.getElementById('video').innerHTML = |
| 138 | +"<video controls width='640'><source src='" + |
| 139 | +bid.vastUrl + |
| 140 | +"' type='video/mp4'></video>"; |
| 141 | +} else { |
| 142 | +document.getElementById('video').innerHTML = "Video bid returned but no VAST"; |
| 143 | +} |
| 144 | +} else { |
| 145 | +document.getElementById('video').innerHTML = "No video bid"; |
| 146 | +document.getElementById('video').className += " error"; |
| 147 | +} |
| 148 | + |
| 149 | +/* ================= NATIVE RENDER ================= */ |
| 150 | +var nativeResp = pbjs.getBidResponsesForAdUnitCode('native'); |
| 151 | +if (nativeResp && nativeResp.bids.length) { |
| 152 | +var bid = nativeResp.bids[0]; |
| 153 | + |
| 154 | +if (bid.native) { |
| 155 | +var n = bid.native; |
| 156 | +document.getElementById('native').innerHTML = |
| 157 | +"<h3>" + n.title + "</h3>" + |
| 158 | +"<img src='" + n.image.url + "' width='150'><br>" + |
| 159 | +"<p><strong>" + n.sponsoredBy + "</strong></p>"; |
| 160 | +} else { |
| 161 | +document.getElementById('native').innerHTML = "Native object missing"; |
| 162 | +} |
| 163 | +} else { |
| 164 | +document.getElementById('native').innerHTML = "No native bid"; |
| 165 | +document.getElementById('native').className += " error"; |
| 166 | +} |
| 167 | + |
| 168 | +} |
| 169 | +</script> |
| 170 | + |
| 171 | +</body> |
| 172 | +</html> |
101 | 173 |
|
0 commit comments