Using Prebid.js with Microsoft Monetize Ad Server

About this example:

  • This example shows how to use Prebid.js with Micosoft Monetize Ad Server.
  • See the Seller Tag (AST) documentation for more information.
  • To configure the Seller Tag to use SafeFrames, refer to the SafeFrame API Reference.

Using Prebid.js with Microsoft Monetize Ad Server

Div-1

Div-2
<h5>Div-1</h5>
<div id="div-1">
    <script type="text/javascript">
        apntag.anq.push(function() {
            apntag.showTag('div-1');
        });
    </script>
</div>

<br>

<h5>Div-2</h5>
<div id="div-2">
    <script type="text/javascript">
        apntag.anq.push(function() {
            apntag.showTag('div-2');
        });

    </script>
</div>
var div_1_sizes = [
    [300, 250],
    [300, 600]
];
var div_2_sizes = [
    [728, 90],
    [970, 250]
];
var PREBID_TIMEOUT = 1000;

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

var adUnits = [
    {
        code: 'div-1',
        mediaTypes: {
            banner: {
                sizes: div_1_sizes
            }
        },
        bids: [{
            bidder: 'appnexus',
            params: {
                placementId: 13144370
            }
        }]
    },
    {
        code: 'div-2',
        mediaTypes: {
            banner: {
                sizes: div_2_sizes
            }
        },
        bids: [{
            bidder: 'appnexus',
            params: {
                placementId: 13144370
            }
        }]
    }
];

pbjs.que.push(function() {
    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
        bidsBackHandler: function(bidResponses) {
            initAdserver();
        },
        timeout: PREBID_TIMEOUT
    });

});

// Prebid Config Section END

var apntag = apntag || {};
apntag.anq = apntag.anq || [];
apntag.anq.push(function() {
    apntag.setPageOpts({
        member: 1543
    });
    apntag.defineTag({
        tagId: 10885450,
        sizes: div_1_sizes,
        targetId: 'div-1'
    });
    apntag.defineTag({
        tagId: 10885450,
        sizes: div_2_sizes,
        targetId: 'div-2'
    });
});

//start loading tags
function initAdserver() {
    if (pbjs.requestSent) {
        return;
    }
    pbjs.requestSent = true;
    pbjs.que.push(function() {
        apntag.anq.push(function() {
            pbjs.setTargetingForAst();
            apntag.loadTags();
        });
    });
}
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Using Prebid.js with Microsoft Monetize Ad Server</title>

    <!-- required scripts -->
    <script async src="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js"></script>
    <script async src="https://acdn.adnxs.com/ast/ast.js"></script>
  </head>
  <body>
  
  <!-- javascript -->
  <script>var div_1_sizes = [
    [300, 250],
    [300, 600]
];
var div_2_sizes = [
    [728, 90],
    [970, 250]
];
var PREBID_TIMEOUT = 1000;

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

var adUnits = [
    {
        code: 'div-1',
        mediaTypes: {
            banner: {
                sizes: div_1_sizes
            }
        },
        bids: [{
            bidder: 'appnexus',
            params: {
                placementId: 13144370
            }
        }]
    },
    {
        code: 'div-2',
        mediaTypes: {
            banner: {
                sizes: div_2_sizes
            }
        },
        bids: [{
            bidder: 'appnexus',
            params: {
                placementId: 13144370
            }
        }]
    }
];

pbjs.que.push(function() {
    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
        bidsBackHandler: function(bidResponses) {
            initAdserver();
        },
        timeout: PREBID_TIMEOUT
    });

});

// Prebid Config Section END

var apntag = apntag || {};
apntag.anq = apntag.anq || [];
apntag.anq.push(function() {
    apntag.setPageOpts({
        member: 1543
    });
    apntag.defineTag({
        tagId: 10885450,
        sizes: div_1_sizes,
        targetId: 'div-1'
    });
    apntag.defineTag({
        tagId: 10885450,
        sizes: div_2_sizes,
        targetId: 'div-2'
    });
});

//start loading tags
function initAdserver() {
    if (pbjs.requestSent) {
        return;
    }
    pbjs.requestSent = true;
    pbjs.que.push(function() {
        apntag.anq.push(function() {
            pbjs.setTargetingForAst();
            apntag.loadTags();
        });
    });
}
</script>

  <!-- html -->
  <h5>Div-1</h5>
<div id="div-1">
    <script type="text/javascript">
        apntag.anq.push(function() {
            apntag.showTag('div-1');
        });
    </script>
</div>

<br>

<h5>Div-2</h5>
<div id="div-2">
    <script type="text/javascript">
        apntag.anq.push(function() {
            apntag.showTag('div-2');
        });

    </script>
</div>

  </body>
</html>
    
This example includes all available adapters and modules. Production implementations should build from source or customize the build using the Download page to make sure only the necessary bidder adapters and modules are included.

Further Reading