|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Optable Web SDK Demos</title> |
| 6 | + <meta name="description" content="Optable Web SDK Demos" /> |
| 7 | + <meta name="author" content="optable.co" /> |
| 8 | + <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 9 | + <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css" /> |
| 10 | + <link rel="stylesheet" href="/css/normalize.css" /> |
| 11 | + <link rel="stylesheet" href="/css/skeleton.css" /> |
| 12 | + <link rel="icon" type="image/png" href="/images/favicon.png" /> |
| 13 | + |
| 14 | + <!-- Optable web-sdk loader start --> |
| 15 | + <script type="text/javascript"> |
| 16 | + window.optable = window.optable || { cmd: [] }; |
| 17 | +
|
| 18 | + optable.cmd.push(function () { |
| 19 | + optable.instance = new optable.SDK({ |
| 20 | + host: "${DCN_HOST}", |
| 21 | + initPassport: JSON.parse("${DCN_INIT}"), |
| 22 | + site: "${DCN_SITE}", |
| 23 | + cookies: false, |
| 24 | + node: "${DCN_NODE}", |
| 25 | + }); |
| 26 | +
|
| 27 | + optable.instance.tryIdentifyFromParams(); |
| 28 | + }); |
| 29 | + </script> |
| 30 | + <script async src="${SDK_URI}"></script> |
| 31 | + <!-- Optable web-sdk loader end --> |
| 32 | + |
| 33 | + <!-- Optable web-sdk inject targeting start --> |
| 34 | + <script> |
| 35 | + // Hook GPT event listeners and send events to DCN: |
| 36 | + optable.cmd.push(function () { |
| 37 | + optable.instance.installGPTEventListeners(); |
| 38 | + }); |
| 39 | +
|
| 40 | + // Try to fetch and cache targeting data from DCN: |
| 41 | + optable.cmd.push(function () { |
| 42 | + optable.instance.targeting().catch((err) => { |
| 43 | + console.log("[OptableSDK] targeting() exception: " + err.message); |
| 44 | + }); |
| 45 | + }); |
| 46 | + </script> |
| 47 | + <!-- Optable web-sdk inject targeting end --> |
| 48 | + |
| 49 | + <!-- GPT header tag start --> |
| 50 | + <script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> |
| 51 | + <script> |
| 52 | + window.googletag = window.googletag || { cmd: [] }; |
| 53 | +
|
| 54 | + googletag.cmd.push(function () { |
| 55 | + headerAd = googletag |
| 56 | + .defineSlot('/22081946781/agentic-buyer-demo', [728, 90], 'div-gpt-ad-1761329463906-0') |
| 57 | + .addService(googletag.pubads()); |
| 58 | +
|
| 59 | + // Setup page-level GAM targeting from any cached targeting data and load ads as usual: |
| 60 | + optable.cmd.push(function () { |
| 61 | + const gamTargeting = optable.instance.targetingKeyValuesFromCache(); |
| 62 | +
|
| 63 | + if (gamTargeting) { |
| 64 | + for (const [key, values] of Object.entries(gamTargeting)) { |
| 65 | + googletag.pubads().setTargeting(key, values); |
| 66 | + console.log("[OptableSDK] googletag.pubads().setTargeting(" + key + ", [" + values + "])"); |
| 67 | + } |
| 68 | + } |
| 69 | +
|
| 70 | + googletag.pubads().enableSingleRequest(); |
| 71 | + googletag.enableServices(); |
| 72 | +
|
| 73 | + console.log("[GPT] googletag.enableServices()"); |
| 74 | + }); |
| 75 | + }); |
| 76 | + </script> |
| 77 | + <!-- GPT header tag end --> |
| 78 | + </head> |
| 79 | + <body> |
| 80 | + <div class="container"> |
| 81 | + <div class="row"> |
| 82 | + <div class="twelve column" style="margin-top: 5%;"> |
| 83 | + <a href="/"><img src="/images/logo.png" width="200" /></a> |
| 84 | + <hr /> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + |
| 88 | + <div class="row"> |
| 89 | + <div class="twelve column"> |
| 90 | + <h4>Example: targeting API: GAM360 (AdCP)</h4> |
| 91 | + <p> |
| 92 | + Shows how to load and cache active cohorts in a visitor's browser. Separately, cached cohorts are passed to |
| 93 | + <a href="https://admanager.google.com/home/">Google Ad Manager</a> (GAM) via the |
| 94 | + <a href="https://developers.google.com/publisher-tag/guides/get-started">Google Publisher Tag</a> (GPT) for |
| 95 | + ad targeting. |
| 96 | + </p> |
| 97 | + <p> |
| 98 | + In this example, we use the <code>targetingKeyValuesFromCache()</code> API to retrieve any targeting data from |
| 99 | + browser LocalStorage, in order to pass it to GPT via <code>googletag.pubads().setTargeting()</code>. We also |
| 100 | + call the SDK <code>targeting</code> API which will fetch the latest targeting data from our DCN and |
| 101 | + cache it locally for later use. Since these two events happen asynchronously, it's possible that the |
| 102 | + targeting data passed to GAM is slightly outdated. To ensure ad targeting accuracy, it is recommended to call |
| 103 | + <code>targeting</code> to update the local cache on page load. |
| 104 | + </p> |
| 105 | + <p> |
| 106 | + If you are comfortable with disabling initial load on GAM ads and always loading them explicitly with the |
| 107 | + very latest targeting data, have a look at the |
| 108 | + <a href="/vanilla/targeting/gam360.html">original targeting & GAM360 activation</a> example instead. |
| 109 | + </p> |
| 110 | + </div> |
| 111 | + </div> |
| 112 | + |
| 113 | + <div class="row"> |
| 114 | + <div class="twelve column"> |
| 115 | + <h5>agentic-buyer-demo/728x90</h5> |
| 116 | + <!-- GAM360 Ad Unit slot: agentic-buyer-demo/728x90 --> |
| 117 | + <div id="div-gpt-ad-1761329463906-0" style="width: 728px; height: 90px;"></div> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + <div class="row"> |
| 121 | + <div class="twelve column" style="font-size: 0.8rem; padding: 10px;"> |
| 122 | + <center> |
| 123 | + <a href="https://www.optable.co/">Home</a> | <a href="https://www.optable.co/company/contact">Contact</a> | |
| 124 | + <a href="https://terms.optable.co/">Terms</a> | |
| 125 | + <a href="https://www.linkedin.com/company/optableco/">LinkedIn</a> | |
| 126 | + <a href="https://twitter.com/optable_co">Twitter</a> |
| 127 | + </center> |
| 128 | + </div> |
| 129 | + </div> |
| 130 | + </div> |
| 131 | + |
| 132 | + <!-- GPT body tag start --> |
| 133 | + <script> |
| 134 | + googletag.cmd.push(function () { |
| 135 | + googletag.display(headerAd); |
| 136 | +
|
| 137 | + console.log("[GPT] googletag.display() all slots"); |
| 138 | + }); |
| 139 | + </script> |
| 140 | + <!-- GPT body tag end --> |
| 141 | + </body> |
| 142 | +</html> |
0 commit comments