Skip to content

Commit 51e5602

Browse files
authored
datamage rtd contextual provider: initial release (#14485)
* Create datamage RTD integration * remove test.html files * update example.html * siplify architecture, adding back in linting, improve load * fixed caching issues and bot comments from original pr * fix issues identified by bot * replace dep GPT api calls to modern format * update btoa to support non typical url encodings, strip common tracking params * remove misc local test files * fix fetchPromise transient failur potential * reduce key value size and unusued keys in payload to gam and ortb * update Rtd spec file naming * update prebid js path in example * include datamageRtdprovider in submodules json
1 parent 6f9fd36 commit 51e5602

File tree

5 files changed

+824
-1
lines changed

5 files changed

+824
-1
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>OpsMage Prebid Test Page</title>
7+
8+
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js" crossorigin="anonymous"></script>
9+
<script>
10+
window.googletag = window.googletag || { cmd: [] };
11+
window.gptSlot = null;
12+
13+
googletag.cmd.push(function () {
14+
googletag.pubads().disableInitialLoad();
15+
16+
// Save slot reference so we can refresh JUST this slot
17+
window.gptSlot = googletag.defineSlot(
18+
'/50536250/designcon',
19+
[[300, 250]],
20+
'div-gpt-ad-1771335974713-0'
21+
).addService(googletag.pubads());
22+
23+
googletag.pubads().enableSingleRequest();
24+
googletag.enableServices();
25+
26+
// Display once (no request yet because disableInitialLoad)
27+
googletag.display('div-gpt-ad-1771335974713-0');
28+
});
29+
30+
// Helper function to verify targeting in the console
31+
function dumpGptTargeting(label) {
32+
googletag.cmd.push(function () {
33+
const pubads = googletag.pubads();
34+
const keys = pubads.getTargetingKeys();
35+
const pubadsMap = {};
36+
keys.forEach(k => { pubadsMap[k] = pubads.getTargeting(k); });
37+
38+
console.log(label, 'PUBADS targeting:', pubadsMap);
39+
40+
if (window.gptSlot && typeof window.gptSlot.getTargetingMap === 'function') {
41+
console.log(label, 'SLOT targeting:', window.gptSlot.getTargetingMap());
42+
}
43+
});
44+
}
45+
</script>
46+
47+
<script async src="../../build/dev/prebid.js"></script>
48+
49+
<script>
50+
var pbjs = window.pbjs = window.pbjs || {};
51+
pbjs.que = pbjs.que || [];
52+
53+
var PREBID_TIMEOUT = 1500;
54+
55+
var adUnits = [{
56+
code: 'div-gpt-ad-1771335974713-0',
57+
mediaTypes: { banner: { sizes: [[300, 250]] } },
58+
bids: [{
59+
bidder: 'appnexus',
60+
params: { placementId: 1234567 }
61+
}]
62+
}];
63+
64+
pbjs.que.push(function () {
65+
pbjs.setConfig({
66+
debug: true,
67+
68+
consentManagement: {
69+
allowAuctionWithoutConsent: true,
70+
gdpr: {
71+
cmpApi: 'static',
72+
timeout: 0,
73+
consentData: {
74+
getTCData: {
75+
tcString: 'CPAa+2APAa+2AAOACBENC1CoAP_AAH_AAAAAAwwxgAAAAA',
76+
gdprApplies: true,
77+
purpose: { consents: { 1: true, 2: true, 3: true, 4: true, 5: true } },
78+
vendor: { consents: { 1: true }, legitimateInterests: { 1: true } }
79+
}
80+
}
81+
},
82+
usp: { cmpApi: 'static', timeout: 0, consentData: { getUSPData: { uspString: '1---' } } }
83+
},
84+
85+
allowActivities: {
86+
accessDevice: { rules: [{ action: 'allow' }] },
87+
enrichUfpd: { rules: [{ action: 'allow' }] },
88+
enrichEids: { rules: [{ action: 'allow' }] },
89+
transmitTid: { rules: [{ action: 'allow' }] }
90+
},
91+
92+
realTimeData: {
93+
auctionDelay: 1000, // Prebid will wait up to 1000ms for Datamage to fetch data
94+
dataProviders: [{
95+
name: "datamage",
96+
waitForIt: true, // <--- CRITICAL FIX: Forces Prebid to wait for this module
97+
params: {
98+
api_key: '8328309832',
99+
selector: 'article',
100+
fetch_timeout_ms: 2500
101+
}
102+
}]
103+
}
104+
});
105+
106+
pbjs.addAdUnits(adUnits);
107+
108+
pbjs.requestBids({
109+
bidsBackHandler: function () {
110+
// Push standard header bidding keys (like hb_pb) to GPT
111+
pbjs.setTargetingForGPTAsync();
112+
113+
// Dump targeting to verify Datamage was successfully pushed via setConfig
114+
dumpGptTargeting('[before refresh]');
115+
116+
// Refresh only our specific slot
117+
googletag.cmd.push(function () {
118+
if (window.gptSlot) {
119+
googletag.pubads().refresh([window.gptSlot]);
120+
} else {
121+
// Fallback
122+
googletag.pubads().refresh();
123+
}
124+
});
125+
},
126+
timeout: PREBID_TIMEOUT
127+
});
128+
});
129+
</script>
130+
</head>
131+
132+
<body>
133+
<h2>OpsMage Prebid Test Page</h2>
134+
<div id="div-gpt-ad-1771335974713-0" style="width:300px; height:250px;"></div>
135+
<article>The tech world is currently buzzing over the highly anticipated market debut of fakeDSP, a trailblazing
136+
startup poised to redefine the landscape of digital signal processing. Leveraging proprietary neuromorphic
137+
algorithms and quantum-ready architecture, fakeDSP promises to accelerate real-time data synthesis by speeds
138+
previously thought impossible. With early analysts calling it a definitive disruptor in both the
139+
telecommunications and audio-engineering sectors, the company’s entrance signifies a major leap forward in how
140+
complex signals are analyzed and reconstructed in the AI era.</article>
141+
</body>
142+
143+
</html>

modules/.submodules.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"cleanioRtdProvider",
8585
"confiantRtdProvider",
8686
"contxtfulRtdProvider",
87+
"datamageRtdProvider",
8788
"dgkeywordRtdProvider",
8889
"dynamicAdBoostRtdProvider",
8990
"experianRtdProvider",
@@ -139,4 +140,4 @@
139140
"adplayerproVideoProvider"
140141
]
141142
}
142-
}
143+
}

0 commit comments

Comments
 (0)