【问题标题】:Why does DFP/GAM setTargeting option not work with prebid?为什么 DFP/GAM setTargeting 选项不适用于预出价?
【发布时间】:2019-02-06 16:07:47
【问题描述】:

当我们使用 DFP 选项来定位具有键/值对的广告时,我们注意到它在 Prebid 也运行时不起作用。 Prebid 似乎覆盖了 setTargeting 选项。这似乎是一个常见问题,但我找不到任何相关信息。

如果我禁用 prebid,setTargeting 工作正常。

我还尝试将 setTargeting 放在 pbjs.que.push 函数中,就在 pbjs.setTargetingForGPTAsync(); 之后但这没有帮助。

我已经对代码进行了配对,仅包含基本设置,以显示我们是如何配置的。

<script src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script type="text/javascript" src="https://ads.bninews.com/corporate/prebid/latest/prebid.js"></script>
<script type="text/javascript" src="https://ads.bninews.com/corporate/prebid/latest/prebid_config.js?20180913"></script>

<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
</script>

<script>
googletag.cmd.push(function() {
  googletag.defineSlot('/XXX/slot-300x250-1', [[300, 250]], 'div-gpt-ad-bigblock-1').addService(googletag.pubads());
  googletag.pubads().setTargeting("pageurl", "/home/");
  googletag.pubads().enableSingleRequest();
  googletag.pubads().disableInitialLoad();
  googletag.enableServices();
});
</script>

<!-- Prebid Boilerplate Section START -->
<script>
  pbjs.que.push(function() {
    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
      bidsBackHandler: initAdserver,
      timeout: PREBID_TIMEOUT
    });
  });
  function initAdserver() {
    if (pbjs.initAdserverSet) return;
    pbjs.initAdserverSet = true;
    googletag.cmd.push(function() {
      pbjs.que.push(function() {
        pbjs.setTargetingForGPTAsync();
        googletag.pubads().refresh();
      });
    });
  }
  // in case PBJS doesn't load
  setTimeout(function() {
    initAdserver();
  }, FAILSAFE_TIMEOUT);
</script>
<!-- Prebid Boilerplate Section END -->

【问题讨论】:

  • 是否有可以观察此行为的页面?
  • 当然可以。我设置了一个测试广告来定位此页面右侧边栏中的第 4 个广告位。 vicksburgpost.com/2016/02/20/… 它应该只显示一个灰色框。但是,目前正在显示另一个广告。我可以删除 key:value 对,它显示正常,我也可以关闭 Prebid,它会显示正常..

标签: google-dfp prebid.js prebid


【解决方案1】:

肯定是事件的顺序是错误的。我什至认为根本不需要 pbjs.setTargetingForGPTAsync() ,但是您确实需要在 googletag.pubads().setTargeting("pageurl", "/home/");

您可以使用一个包裹在 prebid 周围的 Promise 来解决这个问题,然后等待 Promise 在内部解决,例如:

var prebidPromiseResponse = new Promise( function(resolve){ 

pbjs.que.push(function() {
    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
      bidsBackHandler: function(bids){
       if (pbjs.initAdserverSet) return;
       pbjs.initAdserverSet = true;
       googletag.cmd.push(function() {
        pbjs.que.push(function() {
           resolve(bids);
        });
      });
      },
      timeout: PREBID_TIMEOUT
    });
  });
})

然后是谷歌标签

googletag.cmd.push(function() {
  googletag.defineSlot('/XXX/slot-300x250-1', [[300, 250]], 'div-gpt-ad-bigblock-1').addService(googletag.pubads());
  prebidPromiseResponse.then(function(bids){
  googletag.pubads().setTargeting("pageurl", "/home/");
  googletag.pubads().enableSingleRequest();
  googletag.pubads().disableInitialLoad();
  googletag.enableServices();
});
});

【讨论】:

  • 我不确定我是否正确处理了它,但我已经重新配置了我的测试页面以执行类似于您概述的操作。虽然我确实必须添加“googletag.pubads().refresh();”在 promise.then 函数中。我看到了目标广告(侧边栏中的最后一个大块广告,它只是灰色的)。但是,当我在控制台中运行 pbjs.getAllPrebidWinningBids() 时,它不会返回任何中标。这是那个测试页面:vicksburgpost.com/2016/02/20/…
猜你喜欢
  • 1970-01-01
  • 2017-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-26
  • 1970-01-01
相关资源
最近更新 更多