Monetization Framework

Batch Requests

If you have multiple ad zones running custom ad format on the same page, you can reduce network calls by batching the requests together using initBatch instead of init.

Converting your ad call from a single call to a batch call

This is relatively straight-forward. Let's say you have two custom ad units on the same page. Currently, your code might looks like this:

Example of making several ad requests for multiple zones


<div id="top-placement"></div>
<div id="bottom-placement"></div>

<script>
(function() {
  if (typeof _bsa !== 'undefined' && _bsa) {
    _bsa.init('custom', 'CVADC53U', 'placement:yoursitecom-top-placement', {
        target: '#top-placement',
        template: `
        <a class="sponsor-bar" style="background-color: ##backgroundColor##; color: ##textColor##" href="##statlink##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
        <img class="sponsor-icon" src="##image##">
        <div class="sponsor-text">##company## — ##tagline##</div>
        </a>
        `,
    });

    _bsa.init('custom', 'CVADC53U', 'placement:yoursitecom-bottom-placement', {
        target: '#bottom-placement',
        template: `
        <a class="sponsor-bar" style="background-color: ##backgroundColor##; color: ##textColor##" href="##statlink##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
        <img class="sponsor-icon" src="##image##">
        <div class="sponsor-text">##company## — ##tagline##</div>
        </a>
        `,
    });
  }
})();
</script>

The code above creates two requests to the ad server. To batch this into a single request to the ad server, you simply change init to initBatch and call loadBatch to send the request:

Example of combining multiple ad requests into one


<div id="top-placement"></div>
<div id="bottom-placement"></div>

<script>
(function() {
  if (typeof _bsa !== 'undefined' && _bsa) {
    _bsa.initBatch('custom', 'CVADC53U', 'placement:yoursitecom-top-placement', {
        target: '#top-placement',
        template: `
        <a class="sponsor-bar" style="background-color: ##backgroundColor##; color: ##textColor##" href="##statlink##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
        <img class="sponsor-icon" src="##image##">
        <div class="sponsor-text">##company## — ##tagline##</div>
        </a>
        `,
    });

    _bsa.initBatch('custom', 'CVADC53U', 'placement:yoursitecom-bottom-placement', {
        target: '#bottom-placement',
        template: `
        <a class="sponsor-bar" style="background-color: ##backgroundColor##; color: ##textColor##" href="##statlink##" rel="sponsored noopener" target="_blank" title="##company## — ##tagline##">
        <img class="sponsor-icon" src="##image##">
        <div class="sponsor-text">##company## — ##tagline##</div>
        </a>
        `,
    });
    _bsa.loadBatch();
  }
})();

</script>

This will also work for custom templates.