首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Prebid不使用配置的大小呈现广告

Prebid不使用配置的大小呈现广告
EN

Stack Overflow用户
提问于 2021-02-16 18:14:28
回答 1查看 60关注 0票数 1

我在移动设备上测试Prebid。在我的AdUnit中,我定义了如下尺寸:

Prebid parameters

但是,我得到了不同维度的广告:

Prebid sizes

在我看来,广告商不理解广告是在移动设备上显示的,也许这就是问题所在。也许有一个参数我忘了。

我在iFrame里玩我的拍卖,也许这就是问题所在。

我使用的是4.25版本。

如果我的帖子不正确或不完整,请告诉我,这是我在stackoverflow上的第一篇帖子。

非常感谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2021-02-16 22:42:47

问题就解决了。你可以在这里看到详细信息:https://github.com/prebid/Prebid.js/issues/6307

如果使用ImproveDigital适配器,只需在pbjs.setConfig中添加improvedigital: {usePrebidSizes: true}

pbjs.setConfig({ improvedigital: {usePrebidSizes: true} });

我的完整示例如下:

HTML页面:

代码语言:javascript
复制
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="testmobile.js"></script>
  </head>
  <body>
    <div id="b48fef10-6f72-4f83-9a91-77c42069bd87">
    
    </div>
  </body>
</html>

javascript代码:

代码语言:javascript
复制
/** add your prebid dll here or in html file **/

let adUnits = [];

let adUnit =
{
    code: "b48fef10-6f72-4f83-9a91-77c42069bd87",
    mediaTypes: {
        banner: {
          sizes: [[300,100],[320,100],[320,50],[300,50]]
        }
    },
    bids: [
    {
        bidder:"onetag",
        params:{
          pubId:"xxxxxxxxxxxxxxxxx"
        }
    },
    {
        bidder:"appnexus",
        params:
        {
            placementId:"xxxxxxxxxxxxxxxxx"
        }
    },
    {
        bidder:"improvedigital",
        params:
        {
            placementId:"xxxxxxxxxxxxxxxxx"
        }
    }]
};

adUnits.push(adUnit);

pbjs.que.push(function () {
    pbjs.setConfig({
        debug: true,
        improvedigital: {usePrebidSizes: true}
    });

    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
        bidsBackHandler: function (bidResponses) {
        var winningBids = [];

        let ad = pbjs.getHighestCpmBids("b48fef10-6f72-4f83-9a91-77c42069bd87");

        if (ad && ad.length > 0) {
            let idIFrame = "b48fef10-6f72-4f83-9a91-77c42069bd87frame";

            let iFrame = "<iframe id='" + idIFrame + "'"
            + " FRAMEBORDER=\"0\""
            + " SCROLLING=\"no\""
            + " MARGINHEIGHT=\"0\""
            + " MARGINWIDTH=\"0\""
            + " TOPMARGIN=\"0\""
            + " LEFTMARGIN=\"0\""
            + " ALLOWTRANSPARENCY=\"true\""
            + " WIDTH=\"0\""
            + " HEIGHT=\"0\">."
            + " </iframe>"

            document.body.innerHTML += '<div id=b48fef10-6f72-4f83-9a91-77c42069bd87>' + iFrame + '</div>';

            var iframe = document.getElementById(idIFrame);
            var iframeDoc = iframe.contentWindow.document;

            try {
                pbjs.renderAd(iframeDoc, ad[0]['adId']);
            } catch (e) {
                console.log(e);
            }

            winningBids = pbjs.getAllWinningBids();
            console.log(winningBids);
        } 
        else 
        {
          console.log("No bids");
        };
    },
        timeout: 2000
    });
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66222448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档