|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta http-equiv="Delegate-CH" content="sec-ch-ua-full-version-list https://cloud.51degrees.com; sec-ch-ua-model https://cloud.51degrees.com; sec-ch-ua-platform https://cloud.51degrees.com; sec-ch-ua-platform-version https://cloud.51degrees.com"> |
| 5 | + <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> |
| 6 | + <script async src="../../build/dev/prebid.js"></script> |
| 7 | + <meta charset="utf-8"> |
| 8 | + <style> |
| 9 | + body { |
| 10 | + color: #555; |
| 11 | + font-family: sans-serif; |
| 12 | + } |
| 13 | + </style> |
| 14 | + <script> |
| 15 | + var PREBID_TIMEOUT = 1000; |
| 16 | + var FAILSAFE_TIMEOUT = 3000; |
| 17 | + |
| 18 | + var googletag = googletag || {}; |
| 19 | + googletag.cmd = googletag.cmd || []; |
| 20 | + |
| 21 | + var pbjs = pbjs || {}; |
| 22 | + pbjs.que = pbjs.que || []; |
| 23 | + |
| 24 | + function initAdserver() { |
| 25 | + if (pbjs.initAdserverSet) return; |
| 26 | + |
| 27 | + googletag.cmd.push(function () { |
| 28 | + pbjs.que.push(function () { |
| 29 | + pbjs.setTargetingForGPTAsync(); |
| 30 | + googletag.pubads().refresh(); |
| 31 | + }); |
| 32 | + }); |
| 33 | + |
| 34 | + pbjs.initAdserverSet = true; |
| 35 | + } |
| 36 | + |
| 37 | + pbjs.que.push(function () { |
| 38 | + var adUnits = [{ |
| 39 | + code: 'div-banner-native-1', |
| 40 | + mediaTypes: { |
| 41 | + banner: { |
| 42 | + sizes: [ |
| 43 | + [300, 250] |
| 44 | + ] |
| 45 | + }, |
| 46 | + native: { |
| 47 | + type: 'image' |
| 48 | + }, |
| 49 | + }, |
| 50 | + bids: [{ |
| 51 | + bidder: 'appnexus', |
| 52 | + params: { |
| 53 | + placementId: 13232392, |
| 54 | + } |
| 55 | + }] |
| 56 | + }, |
| 57 | + { |
| 58 | + code: 'div-banner-native-2', |
| 59 | + mediaTypes: { |
| 60 | + banner: { |
| 61 | + sizes: [ |
| 62 | + [300, 250] |
| 63 | + ] |
| 64 | + }, |
| 65 | + native: { |
| 66 | + title: { |
| 67 | + required: true |
| 68 | + }, |
| 69 | + image: { |
| 70 | + required: true |
| 71 | + }, |
| 72 | + sponsoredBy: { |
| 73 | + required: true |
| 74 | + } |
| 75 | + } |
| 76 | + }, |
| 77 | + bids: [{ |
| 78 | + bidder: 'appnexus', |
| 79 | + params: { |
| 80 | + placementId: 13232392, |
| 81 | + } |
| 82 | + }] |
| 83 | + } |
| 84 | + ]; |
| 85 | + |
| 86 | + pbjs.setConfig({ |
| 87 | + debug: true, // use only for testing, remove in production |
| 88 | + realTimeData: { |
| 89 | + auctionDelay: 1000, // should be set lower in production use |
| 90 | + dataProviders: [ |
| 91 | + { |
| 92 | + name: '51Degrees', |
| 93 | + waitForIt: true, |
| 94 | + params: { |
| 95 | + // Get your resource key from https://configure.51degrees.com/tWrhNfY6 |
| 96 | + resourceKey: '<YOUR_RESOURCE_KEY>', |
| 97 | + // alternatively, you can use the on-premise version of the 51Degrees service and connect to your chosen end point |
| 98 | + // onPremiseJSUrl: 'https://localhost/51Degrees.core.js' |
| 99 | + } |
| 100 | + } |
| 101 | + ] |
| 102 | + }, |
| 103 | + }); |
| 104 | + |
| 105 | + pbjs.addAdUnits(adUnits); |
| 106 | + |
| 107 | + pbjs.onEvent('bidRequested', function (data) { |
| 108 | + try { |
| 109 | + fod.complete(() => { |
| 110 | + document.getElementById('enriched-51').style.display = 'block'; |
| 111 | + document.getElementById('enriched-51-data').textContent = JSON.stringify(data.ortb2.device, null, 2); |
| 112 | + }); |
| 113 | + } catch (e) { |
| 114 | + console.error('Error while trying to display enriched data', e); |
| 115 | + } |
| 116 | + }); |
| 117 | + |
| 118 | + pbjs.requestBids({ |
| 119 | + timeout: PREBID_TIMEOUT, |
| 120 | + bidsBackHandler: function (bidResponses) { |
| 121 | + initAdserver(); |
| 122 | + } |
| 123 | + }); |
| 124 | + }); |
| 125 | + setTimeout(initAdserver, FAILSAFE_TIMEOUT); |
| 126 | + </script> |
| 127 | + |
| 128 | + <script> |
| 129 | + googletag.cmd.push(function () { |
| 130 | + googletag |
| 131 | + .defineSlot( |
| 132 | + '/19968336/prebid_multiformat_test', [ |
| 133 | + [300, 250], |
| 134 | + [360, 360] |
| 135 | + ], |
| 136 | + 'div-banner-native-1' |
| 137 | + ) |
| 138 | + .addService(googletag.pubads()); |
| 139 | + |
| 140 | + googletag |
| 141 | + .defineSlot( |
| 142 | + '/19968336/prebid_multiformat_test', [ |
| 143 | + [300, 250], |
| 144 | + [360, 360] |
| 145 | + ], |
| 146 | + 'div-banner-native-2' |
| 147 | + ) |
| 148 | + .addService(googletag.pubads()); |
| 149 | + |
| 150 | + googletag.pubads().disableInitialLoad(); |
| 151 | + googletag.pubads().enableSingleRequest(); |
| 152 | + googletag.enableServices(); |
| 153 | + }); |
| 154 | + </script> |
| 155 | + <title>51Degrees RTD submodule example - Prebid.js</title> |
| 156 | +</head> |
| 157 | +<body> |
| 158 | + <h2>51Degrees RTD submodule - example of usage</h2> |
| 159 | + |
| 160 | + <h3>div-banner-native-1</h3> |
| 161 | + <div id='div-banner-native-1'> |
| 162 | + <p>No response</p> |
| 163 | + <script type='text/javascript'> |
| 164 | + googletag.cmd.push(function () { |
| 165 | + googletag.display('div-banner-native-1'); |
| 166 | + }); |
| 167 | + </script> |
| 168 | + </div> |
| 169 | + |
| 170 | + <h3>div-banner-native-2</h3> |
| 171 | + <div id='div-banner-native-2'> |
| 172 | + <p>No response</p> |
| 173 | + <script type='text/javascript'> |
| 174 | + googletag.cmd.push(function () { |
| 175 | + googletag.display('div-banner-native-2'); |
| 176 | + }); |
| 177 | + </script> |
| 178 | + </div> |
| 179 | + |
| 180 | + <div id="debug"> |
| 181 | + <h3>Testing/Debugging Guidance</h3> |
| 182 | + <ol> |
| 183 | + <li>Make sure you have <code>debug: true</code> under <code>pbjs.setConfig</code> in this example code (be sure to remove it for production!) |
| 184 | + <li>Make sure you have replaced <code><YOUR RESOURCE KEY></code> in this example code with the one you have obtained |
| 185 | + from the <a href="https://configure.51degrees.com/tWrhNfY6" target="blank;">51Degrees Configurator Tool</a></li> |
| 186 | + <li>Open DevTools Console in your browser and refresh the page</li> |
| 187 | + <li>Observe the enriched ortb device data shown below and also in the console as part of the <code>[51Degrees RTD Submodule]: reqBidsConfigObj:</code> message (under <code>reqBidsConfigObj.global.device</code>)</li> |
| 188 | + </ol> |
| 189 | + |
| 190 | + </div> |
| 191 | + <div id="enriched-51" style="display: none"> |
| 192 | + <h3>Enriched ORTB2 device data</h3> |
| 193 | + <pre id="enriched-51-data"></pre> |
| 194 | + </div> |
| 195 | +</body> |
| 196 | +</html> |
0 commit comments