|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <title>Prebid Display/Video Merged Auction with Adloox Integration</title> |
| 5 | + |
| 6 | + <script async src="http://localhost:9999/build/dev/prebid.js"></script> |
| 7 | + <!-- <script async src="https://storage.googleapis.com/adloox-ads-js-test/prebid.js"></script> --> |
| 8 | + <script async src="//www.googletagservices.com/tag/js/gpt.js"></script> |
| 9 | + |
| 10 | + <script> |
| 11 | + // set to 10s (rather than 100ms) only to assist development as 'Local Overrides' stalls for >1s :-/ |
| 12 | + var AUCTION_DELAY = 10000; // recommended to be set to 100 in production |
| 13 | + var PREBID_TIMEOUT = 1000; |
| 14 | + var FAILSAFE_TIMEOUT = AUCTION_DELAY + (3 * PREBID_TIMEOUT); |
| 15 | + |
| 16 | + var div_1_sizes = [ [728, 90] ]; |
| 17 | + var div_2_sizes = [ [300, 250] ]; |
| 18 | + var video_1_size = [ 640, 480 ]; |
| 19 | + |
| 20 | + var adUnits = [ |
| 21 | + { |
| 22 | + code: 'div-1', |
| 23 | + mediaTypes: { |
| 24 | + banner: { |
| 25 | + sizes: div_1_sizes |
| 26 | + } |
| 27 | + }, |
| 28 | + bids: [ |
| 29 | + { |
| 30 | + bidder: 'rubicon', |
| 31 | + params: { |
| 32 | + accountId: 14062, |
| 33 | + siteId: 70608, |
| 34 | + zoneId: 498816 |
| 35 | + } |
| 36 | + } |
| 37 | + ] |
| 38 | + }, |
| 39 | + { |
| 40 | + code: 'div-2', |
| 41 | + mediaTypes: { |
| 42 | + banner: { |
| 43 | + sizes: div_2_sizes |
| 44 | + } |
| 45 | + }, |
| 46 | + bids: [ |
| 47 | + { |
| 48 | + bidder: 'rubicon', |
| 49 | + params: { |
| 50 | + accountId: 14062, |
| 51 | + siteId: 70608, |
| 52 | + zoneId: 498816 |
| 53 | + } |
| 54 | + } |
| 55 | + ] |
| 56 | + } |
| 57 | + ]; |
| 58 | + |
| 59 | + var videoAdUnit = { |
| 60 | + code: 'video-1', |
| 61 | + mediaTypes: { |
| 62 | + video: { |
| 63 | + context: 'instream', |
| 64 | + playerSize: [ 640, 480 ] |
| 65 | + } |
| 66 | + }, |
| 67 | + fpd: { |
| 68 | + context: { |
| 69 | + pbAdSlot: '/19968336/prebid_cache_video_adunit' |
| 70 | + } |
| 71 | + }, |
| 72 | + bids: [ |
| 73 | + { |
| 74 | + bidder: 'spotx', |
| 75 | + params: { |
| 76 | + channel_id: 85394, |
| 77 | + ad_unit: 'instream' |
| 78 | + } |
| 79 | + } |
| 80 | + ] |
| 81 | + }; |
| 82 | + |
| 83 | + window.googletag = window.googletag || { cmd: [] }; |
| 84 | + googletag.cmd.push(function() { |
| 85 | + googletag |
| 86 | + .defineSlot('/19968336/header-bid-tag-0', div_1_sizes, 'div-1') |
| 87 | + .addService(googletag.pubads()); |
| 88 | + googletag |
| 89 | + .defineSlot('/19968336/header-bid-tag-1', div_2_sizes, 'div-2') |
| 90 | + .addService(googletag.pubads()); |
| 91 | + googletag.pubads().disableInitialLoad(); |
| 92 | + googletag.pubads().enableSingleRequest(); |
| 93 | + googletag.enableServices(); |
| 94 | + }); |
| 95 | + |
| 96 | + var pbjs = pbjs || {}; |
| 97 | + pbjs.que = pbjs.que || []; |
| 98 | + |
| 99 | + var tempTag = false; |
| 100 | + var invokeVideoPlayer = function(url) { |
| 101 | + tempTag = url; |
| 102 | + }; |
| 103 | + |
| 104 | + function sendAdserverRequest(bids, timedOut, auctionId) { |
| 105 | + if (pbjs.initAdserverSet) return; |
| 106 | + pbjs.initAdserverSet = true; |
| 107 | + |
| 108 | + googletag.cmd.push(function() { |
| 109 | + pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync(adUnits); |
| 110 | + googletag.pubads().refresh(); |
| 111 | + }); |
| 112 | + |
| 113 | + var videoBids = bids[videoAdUnit.code]; |
| 114 | + if (videoBids) { |
| 115 | + var videoUrl = videoBids.bids[0].vastUrl; |
| 116 | +// var videoUrl = pbjs.adServers.dfp.buildVideoUrl({ |
| 117 | +// adUnit: videoAdUnit, |
| 118 | +// params: { |
| 119 | +// iu: '/19968336/prebid_cache_video_adunit', |
| 120 | +// cust_params: { |
| 121 | +// section: 'blog', |
| 122 | +// anotherKey: 'anotherValue' |
| 123 | +// }, |
| 124 | +// output: 'vast' |
| 125 | +// } |
| 126 | +// }); |
| 127 | + invokeVideoPlayer(videoUrl); |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + // optionally wrap with googletag to have gpt-pre-auction |
| 132 | + // automatically populate Prebid Ad Slot (pbAdSlot) |
| 133 | + // https://docs.prebid.org/dev-docs/modules/gpt-pre-auction.html |
| 134 | + // alternatively remove wrapping and set AdUnit.fpd.context.pbAdSlot |
| 135 | + googletag.cmd.push(function() { |
| 136 | + pbjs.que.push(function() { |
| 137 | + pbjs.setConfig({ |
| 138 | + instreamTracking: { |
| 139 | + enabled: true |
| 140 | + }, |
| 141 | + rubicon: { |
| 142 | + singleRequest: true |
| 143 | + } |
| 144 | + }); |
| 145 | + pbjs.enableAnalytics({ |
| 146 | + provider: 'adloox', |
| 147 | + options: { |
| 148 | + client: 'adlooxtest', |
| 149 | + clientid: 127, |
| 150 | + platformid: 0, |
| 151 | + tagid: 0 |
| 152 | + } |
| 153 | + }); |
| 154 | + pbjs.addAdUnits(adUnits); |
| 155 | + pbjs.addAdUnits(videoAdUnit); |
| 156 | + pbjs.requestBids({ |
| 157 | + bidsBackHandler: sendAdserverRequest, |
| 158 | + timeout: PREBID_TIMEOUT |
| 159 | + }) |
| 160 | + }); |
| 161 | + }); |
| 162 | + |
| 163 | + setTimeout(function() { |
| 164 | + sendAdserverRequest(); |
| 165 | + }, FAILSAFE_TIMEOUT); |
| 166 | + </script> |
| 167 | + </head> |
| 168 | + <body> |
| 169 | + <h1>Prebid Display/Video Merged Auction with Adloox Integration</h1> |
| 170 | + |
| 171 | + <h2>div-1</h2> |
| 172 | + <div id="div-1"> |
| 173 | + <script> |
| 174 | + googletag.cmd.push(function() { |
| 175 | + googletag.display('div-1'); |
| 176 | + }); |
| 177 | + </script> |
| 178 | + </div> |
| 179 | + |
| 180 | + <h2>div-2</h2> |
| 181 | + <div id="div-2"> |
| 182 | + <script> |
| 183 | + googletag.cmd.push(function() { |
| 184 | + googletag.display('div-2'); |
| 185 | + }); |
| 186 | + </script> |
| 187 | + </div> |
| 188 | + |
| 189 | + <h2>video-1</h2> |
| 190 | + <div id="video-1"></div> |
| 191 | + <script src="https://content.jwplatform.com/libraries/72xIKEe6.js"></script> |
| 192 | + <script> |
| 193 | + var playerInstance = jwplayer('video-1'); |
| 194 | + invokeVideoPlayer = function(url) { |
| 195 | + playerInstance.setup({ |
| 196 | + "playlist": "https://content.jwplatform.com/feeds/ae4tmw2D.json", |
| 197 | + "width": 640, |
| 198 | + "height": 480, |
| 199 | + "advertising": { |
| 200 | + "client": "vast", |
| 201 | + "tag": url |
| 202 | + } |
| 203 | + }); |
| 204 | + }; |
| 205 | + if (tempTag) { |
| 206 | + invokeVideoPlayer(tempTag); |
| 207 | + tempTag = false; |
| 208 | + } |
| 209 | + </script> |
| 210 | + </body> |
| 211 | +</html> |
0 commit comments