diff --git a/_includes/video/pb-os-dfp.html b/_includes/video/pb-os-dfp.html index 4496ea51a0..bc7fe61309 100644 --- a/_includes/video/pb-os-dfp.html +++ b/_includes/video/pb-os-dfp.html @@ -48,10 +48,14 @@ if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function () { - pbjs.que.push(function () { - pbjs.setTargetingForGPTAsync(); + if (pbjs.libLoaded) { + pbjs.que.push(function () { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); } diff --git a/dev-docs/examples/basic-example.md b/dev-docs/examples/basic-example.md index 1c22ec8ac6..e4f2519984 100644 --- a/dev-docs/examples/basic-example.md +++ b/dev-docs/examples/basic-example.md @@ -73,8 +73,14 @@ function initAdserver() { if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync(); - googletag.pubads().refresh(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { + googletag.pubads().refresh(); + } }); } diff --git a/dev-docs/examples/custom-price-buckets.md b/dev-docs/examples/custom-price-buckets.md index 7990cfb310..b8bc178adc 100644 --- a/dev-docs/examples/custom-price-buckets.md +++ b/dev-docs/examples/custom-price-buckets.md @@ -97,10 +97,14 @@ function initAdserver() { if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.que.push(function() { - pbjs.setTargetingForGPTAsync(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); } diff --git a/dev-docs/examples/instream-banner-mix.md b/dev-docs/examples/instream-banner-mix.md index 4c6c2bab5f..3bdd997581 100644 --- a/dev-docs/examples/instream-banner-mix.md +++ b/dev-docs/examples/instream-banner-mix.md @@ -177,10 +177,14 @@ function initAdserver(bids) { // Set targeting for each display slot googletag.cmd.push(function() { - pbjs.que.push(function() { - pbjs.setTargetingForGPTAsync(displayAdUnitCodes); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(displayAdUnitCodes); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); // Build DFP URL with targeting for videoAdUnit diff --git a/dev-docs/examples/meta-bid-filtering.md b/dev-docs/examples/meta-bid-filtering.md index d2b8225b66..aae19d1e21 100644 --- a/dev-docs/examples/meta-bid-filtering.md +++ b/dev-docs/examples/meta-bid-filtering.md @@ -78,8 +78,14 @@ function initAdserver() { if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync(); - googletag.pubads().refresh(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { + googletag.pubads().refresh(); + } }); } diff --git a/dev-docs/examples/native-ad-example.md b/dev-docs/examples/native-ad-example.md index 79d01f6759..4d87c6fe72 100644 --- a/dev-docs/examples/native-ad-example.md +++ b/dev-docs/examples/native-ad-example.md @@ -48,10 +48,14 @@ function initAdserver() { if (pbjs.initAdserverSet) return; googletag.cmd.push(function() { - pbjs.que.push(function() { - pbjs.setTargetingForGPTAsync(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); pbjs.initAdserverSet = true; diff --git a/dev-docs/examples/size-mapping.md b/dev-docs/examples/size-mapping.md index 135b18cec2..4ad3401392 100644 --- a/dev-docs/examples/size-mapping.md +++ b/dev-docs/examples/size-mapping.md @@ -104,10 +104,14 @@ function sendAdserverRequest() { if (pbjs.adserverRequestSent) return; pbjs.adserverRequestSent = true; googletag.cmd.push(function() { - pbjs.que.push(function() { - pbjs.setTargetingForGPTAsync(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); } diff --git a/dev-docs/examples/sync-tid.md b/dev-docs/examples/sync-tid.md index d6b1e05074..0922e41ffd 100644 --- a/dev-docs/examples/sync-tid.md +++ b/dev-docs/examples/sync-tid.md @@ -83,9 +83,16 @@ pbjs.que.push(function() { function prebidBidsBack() { pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync(); - requestManager.prebid = true; - sendBidsToAdServer(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + requestManager.prebid = true; + sendBidsToAdServer(); + }); + } else { + googletag.pubads().refresh(); + requestManager.adserverRequestSent = true; + } }); } diff --git a/docs-examples/web-example.md b/docs-examples/web-example.md index 7e88fe7505..79c5246494 100644 --- a/docs-examples/web-example.md +++ b/docs-examples/web-example.md @@ -84,8 +84,14 @@ function initAdserver() { if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync(); - googletag.pubads().refresh(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { + googletag.pubads().refresh(); + } }); } diff --git a/examples/video/outstream/pb-ve-outstream-dfp.html b/examples/video/outstream/pb-ve-outstream-dfp.html index 25f2130937..62d52de1e2 100644 --- a/examples/video/outstream/pb-ve-outstream-dfp.html +++ b/examples/video/outstream/pb-ve-outstream-dfp.html @@ -120,10 +120,14 @@

Place this code in the page header.

if (pbjs.initAdserverSet) return; pbjs.initAdserverSet = true; googletag.cmd.push(function() { - pbjs.que.push(function() { - pbjs.setTargetingForGPTAsync(); + if (pbjs.libLoaded) { + pbjs.que.push(function() { + pbjs.setTargetingForGPTAsync(); + googletag.pubads().refresh(); + }); + } else { googletag.pubads().refresh(); - }); + } }); }