|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + |
| 4 | +<head> |
| 5 | + <title>Measure Lift of Multiple ID Modules</title> |
| 6 | + <script> |
| 7 | + const FAILSAFE_TIMEOUT = 2000; |
| 8 | + const ID_MODULES = [ |
| 9 | + { |
| 10 | + name: "id1", |
| 11 | + params: { key1: "value1", key2: "value2" } |
| 12 | + }, |
| 13 | + { |
| 14 | + name: "id2", |
| 15 | + params: { key3: "value3", key4: "value4" } |
| 16 | + }, |
| 17 | + { |
| 18 | + name: "id3", |
| 19 | + params: { key5: "value5", key6: "value6" } |
| 20 | + } |
| 21 | + ]; |
| 22 | + const TREATMENT_RATE = 0.95; // 95% chance to include an ID module |
| 23 | + const targetingArray = []; |
| 24 | + |
| 25 | + const adUnits = [ |
| 26 | + { |
| 27 | + code: 'test-div', |
| 28 | + mediaTypes: { |
| 29 | + banner: { |
| 30 | + sizes: [[300, 250], [300, 600], [728, 90]] |
| 31 | + }, |
| 32 | + }, |
| 33 | + bids: [ |
| 34 | + { |
| 35 | + bidder: 'rubicon', |
| 36 | + params: { |
| 37 | + accountId: '1001', |
| 38 | + siteId: '113932', |
| 39 | + zoneId: '535510' |
| 40 | + } |
| 41 | + } |
| 42 | + ] |
| 43 | + } |
| 44 | + ]; |
| 45 | + |
| 46 | + var pbjs = pbjs || {}; |
| 47 | + pbjs.que = pbjs.que || []; |
| 48 | + |
| 49 | + var googletag = googletag || {}; |
| 50 | + googletag.cmd = googletag.cmd || []; |
| 51 | + |
| 52 | + // Randomly enable each ID module based on dice rolls |
| 53 | + ID_MODULES.forEach(module => { |
| 54 | + const isEnabled = Math.random() < TREATMENT_RATE; |
| 55 | + targetingArray.push(`${module.name}:${isEnabled ? 't1' : 't0'}`); |
| 56 | + |
| 57 | + if (isEnabled) { |
| 58 | + pbjs.que.push(function () { |
| 59 | + pbjs.mergeConfig({ |
| 60 | + userSync: { |
| 61 | + userIds: [ |
| 62 | + { |
| 63 | + name: module.name, |
| 64 | + params: module.params |
| 65 | + } |
| 66 | + ], |
| 67 | + syncDelay: 5000, |
| 68 | + auctionDelay: 1000, |
| 69 | + } |
| 70 | + }); |
| 71 | + }); |
| 72 | + } |
| 73 | + }); |
| 74 | + |
| 75 | + googletag.cmd.push(function () { |
| 76 | + googletag.pubads().disableInitialLoad(); |
| 77 | + googletag.pubads().setTargeting("abg", targetingArray); |
| 78 | + }); |
| 79 | + |
| 80 | + pbjs.que.push(function () { |
| 81 | + pbjs.setConfig({ debug: true }); |
| 82 | + pbjs.addAdUnits(adUnits); |
| 83 | + pbjs.requestBids({ |
| 84 | + bidsBackHandler: sendAdserverRequest |
| 85 | + }); |
| 86 | + }); |
| 87 | + |
| 88 | + function sendAdserverRequest() { |
| 89 | + if (pbjs.adserverRequestSent) return; |
| 90 | + pbjs.adserverRequestSent = true; |
| 91 | + googletag.cmd.push(function () { |
| 92 | + pbjs.setTargetingForGPTAsync(); |
| 93 | + googletag.pubads().refresh(); |
| 94 | + }); |
| 95 | + } |
| 96 | + |
| 97 | + setTimeout(function () { |
| 98 | + sendAdserverRequest(); |
| 99 | + }, FAILSAFE_TIMEOUT); |
| 100 | + </script> |
| 101 | + |
| 102 | + <script> |
| 103 | + (function () { |
| 104 | + var gads = document.createElement('script'); |
| 105 | + gads.async = true; |
| 106 | + gads.type = 'text/javascript'; |
| 107 | + gads.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js'; |
| 108 | + var node = document.getElementsByTagName('script')[0]; |
| 109 | + node.parentNode.insertBefore(gads, node); |
| 110 | + })(); |
| 111 | + </script> |
| 112 | + |
| 113 | + <script> |
| 114 | + googletag.cmd.push(function () { |
| 115 | + googletag.defineSlot('/112115922/FL_PB_MedRect', [[300, 250], [300, 600], [728, 90]], 'test-div').addService(googletag.pubads()); |
| 116 | + googletag.pubads().enableSingleRequest(); |
| 117 | + googletag.enableServices(); |
| 118 | + }); |
| 119 | + </script> |
| 120 | +</head> |
| 121 | + |
| 122 | +<body> |
| 123 | + <script> |
| 124 | + pbjs.que.push(function () { |
| 125 | + pbjs.getUserIdsAsync().then(ids => { |
| 126 | + document.getElementById('ids-div').innerHTML = JSON.stringify(ids, null, ' '); |
| 127 | + document.getElementById('eids-div').innerHTML = JSON.stringify(pbjs.getUserIdsAsEids(), null, ' '); |
| 128 | + }); |
| 129 | + }); |
| 130 | + </script> |
| 131 | + |
| 132 | + <h2>Measure Lift of Multiple ID Modules</h2> |
| 133 | + |
| 134 | + <h4>Generated IDs:</h4> |
| 135 | + <pre id="ids-div" style="border:1px solid #333; padding:5px; overflow: auto"></pre> |
| 136 | + |
| 137 | + <h4>Generated EIDs:</h4> |
| 138 | + <pre id="eids-div" style="border:1px solid #333; padding:5px; overflow: auto"></pre> |
| 139 | + |
| 140 | + <!-- Instructions Section --> |
| 141 | + <h3>Instructions</h3> |
| 142 | + <ol> |
| 143 | + <li>Ensure that the `abg` key is definied in GAM targeting with all possible keys. Each value will be a combination of the following six possible key-value pairs: |
| 144 | + <ul> |
| 145 | + <li><code>id1:t0</code></li> |
| 146 | + <li><code>id1:t1</code></li> |
| 147 | + <li><code>id2:t0</code></li> |
| 148 | + <li><code>id2:t1</code></li> |
| 149 | + <li><code>id3:t0</code></li> |
| 150 | + <li><code>id3:t1</code></li> |
| 151 | + </ul> |
| 152 | + </li> |
| 153 | + <li>In Google Ad Manager (GAM), create a report with the following setup: |
| 154 | + <ul> |
| 155 | + <li><strong>Dimensions</strong>: Ad Unit, Key-Value Targeting (`abg`).</li> |
| 156 | + <li><strong>Metrics</strong>: Impressions, Revenue.</li> |
| 157 | + <li><strong>Filters</strong>: Include the `abg` key in the report.</li> |
| 158 | + </ul> |
| 159 | + </li> |
| 160 | + <li>Analyze the report for each ID module: |
| 161 | + <ul> |
| 162 | + <li>Filter by combinations of `t1` (treatment) and `t0` (control) for each ID module (e.g., `id1:t1`, `id1:t0`).</li> |
| 163 | + <li>Compare performance metrics (eg Impressions, Revenue) for the `t1` vs. `t0` values.</li> |
| 164 | + <li>Calculate lift for each module using the formula: |
| 165 | + <pre>Lift (%) = ((Treatment Metric / Treatment Rate - Control Metric / Control Rate) / (Control Metric / Control Rate)) * 100</pre> |
| 166 | + Replace "Metric" with the relevant performance metric. |
| 167 | + </li> |
| 168 | + </ul> |
| 169 | + </li> |
| 170 | + </ol> |
| 171 | +</body> |
| 172 | + |
| 173 | +</html> |
0 commit comments