-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmultipleWrapperCall.js
45 lines (33 loc) · 960 Bytes
/
multipleWrapperCall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var HB_TIMEOUT = 2000;
Criteo.RequestBids(CriteoAdUnits, function(){adServerCallback('criteo')}, HB_TIMEOUT);
pbjs.requestBids({
bidsBackHandler: function() { adServerCallback('prebid')}
});
setTimeout(function() {
adServerCallback('timeout');
}, HB_TIMEOUT);
window.hb_status = {
n_adserver_callback: [],
adserverRequestSent: false
};
var adServerCallback = function (source) {
if (window.hb_status.adserverRequestSent) return;
window.hb_status.n_adserver_callback.push(source);
if (source == 'prebid') {
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
});
});
} else if (source == 'criteo') {
googletag.cmd.push(function() {
Criteo.SetDFPKeyValueTargeting();
});
}
if (window.hb_status.n_adserver_callback.length >= 2 || "timeout" == source) {
googletag.cmd.push(function() {
googletag.pubads().refresh();
window.hb_status.adserverRequestSent = true;
});
};
}