2

我也从 Adnuntius 迁移到 GPT 并且正在使用 prebid.js 我需要在每个页面上使用不同的插槽,当我尝试定义它们时,如果我在每个插槽上都有不同的尺寸,我只会让它们工作。假设我在 970x250 上使用第一个并将第二个更改为 300x250 它将起作用。

我认为我的问题是我定义插槽的地方,或者可能是我们的 adunit?

我希望能够对所有插槽使用相同的大小。 site_level是我们来自 gpt 的 adunit 名称

var div_sizes_l = [[970, 250], [980, 200], [980, 240]];
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;

var adUnits = [
    {
        code: 'div-gpt-ad-Landing_Top',  
        mediaTypes: {
            banner: {
                sizes:  div_sizes_l,
            }
        },
        bids: [
            {
                bidder: 'rubicon',
                params: {
                    accountId: '20562',
                    siteId: '2153438',
                    zoneId: '11258332'
                }
            }
        ]
    },
    //
    {
        code: 'div-gpt-ad-Landing_Middle',
        mediaTypes: {
            banner: {
                sizes:  div_sizes_l,
            }
        },
        bids: [
            {
                bidder: 'rubicon',
                params: {
                    accountId: '20562',
                    siteId: '2153438',
                    zoneId: '11258344'
                }
            },
        ]
    },
];

var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function() {
    googletag.pubads().disableInitialLoad();
});

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];

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);

 googletag.cmd = googletag.cmd || [];

 googletag.cmd.push(function() {
    googletag.defineSlot('/21855748559/site_level', 
   div_sizes_l, 
  'div-gpt-ad-Landing_Top').addService(googletag.pubads());
    googletag.pubads().setTargeting('position', 'Landing_Top');

    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
});
googletag.cmd.push(function() {
    googletag.defineSlot('/21855748559/site_level', 
    div_sizes_l, 
   'div-gpt-ad-Landing_Middle').addService(googletag.pubads());
    googletag.pubads().setTargeting('position', 'Landing_Middle');

    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
});
4

1 回答 1

1

您的预出价代码是正确的,它将能够在两个广告单元的所有尺寸的拍卖中使用该变量。但是,因为您使用的是 Rubicon,这就是出现问题的原因。他们的适配器特别需要一组 adunit 尺寸 ID#,然后才能读取并向您传递正确尺寸的出价响应。[查看这里查看他们的文档] ( http://prebid.org/dev-docs/bidders/rubicon.html )。例子:

{
    bidder: 'rubicon',
    params: {
        accountId: '20562',
        siteId: '2153438',
        zoneId: '11258332',
        sizes: [15, 3, 2]
    }
}

这里也是他们的 sizeMap 供您参考以将正确的尺寸 ID 传递给他们,这是直接从他们的 [适配器源] 中提取的(https://github.com/prebid/Prebid.js/blob/master/modules/ rubiconBidAdapter.js):

var sizeMap = {
  1: '468x60',
  2: '728x90',
  5: '120x90',
  8: '120x600',
  9: '160x600',
  10: '300x600',
  13: '200x200',
  14: '250x250',
  15: '300x250',
  16: '336x280',
  17: '240x400',
  19: '300x100',
  31: '980x120',
  32: '250x360',
  33: '180x500',
  35: '980x150',
  37: '468x400',
  38: '930x180',
  39: '750x100',
  40: '750x200',
  41: '750x300',
  42: '2x4',
  43: '320x50',
  44: '300x50',
  48: '300x300',
  53: '1024x768',
  54: '300x1050',
  55: '970x90',
  57: '970x250',
  58: '1000x90',
  59: '320x80',
  60: '320x150',
  61: '1000x1000',
  64: '580x500',
  65: '640x480',
  66: '930x600',
  67: '320x480',
  68: '1800x1000',
  72: '320x320',
  73: '320x160',
  78: '980x240',
  79: '980x300',
  80: '980x400',
  83: '480x300',
  94: '970x310',
  96: '970x210',
  101: '480x320',
  102: '768x1024',
  103: '480x280',
  105: '250x800',
  108: '320x240',
  113: '1000x300',
  117: '320x100',
  125: '800x250',
  126: '200x600',
  144: '980x600',
  145: '980x150',
  152: '1000x250',
  156: '640x320',
  159: '320x250',
  179: '250x600',
  195: '600x300',
  198: '640x360',
  199: '640x200',
  213: '1030x590',
  214: '980x360',
  221: '1x1',
  229: '320x180',
  232: '580x400',
  234: '6x6',
  251: '2x2',
  257: '400x600',
  264: '970x1000',
  265: '1920x1080',
  278: '320x500',
  288: '640x380'
};
于 2020-02-03T17:03:05.297 回答