Prebid not render ad with configurated sizes

348 views Asked by At

I'm testing Prebid on mobile devices. In my AdUnit, I have defined dimensions as follows:

Prebid parameters

But, I get ads with different dimensions:

Prebid sizes

It seems to me that advertisers don't understand that the ad is displayed on a mobile device, maybe that's the problem. Maybe there is a parameter I forgot.

I played my auctions in an iFrame, maybe that's the problem.

I use 4.25 version.

Please tell me if my post is incorrect or incomplete, it's my first post on stackoverflow.

Thank a lot for your help.

1

There are 1 answers

0
Bulle-dog On

The problem is solved. You can see details here: https://github.com/prebid/Prebid.js/issues/6307.

If you use ImproveDigital adapter just add improvedigital: {usePrebidSizes: true} in pbjs.setConfig

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

My full sample here :

The HTML page :

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

The javascript code :

/** 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
    });
});