Standalone Integration

This guide shows how to use n360ortb without an ad server by rendering ads directly from the bid response.

Overview

In standalone mode, you:

  1. Request bids using fetchBids()

  2. Receive the winning bid with ad markup (adm)

  3. Render the ad directly into your page

This approach is ideal for simple implementations or custom ad rendering solutions.

Complete Example

<!DOCTYPE html>
<html>
<head>
  <title>n360ortb Standalone Example</title>

  <!-- n360ortb loader -->
  <script>
  !function(){if(!window.n360ortb){window.n360ortb={init:function(){e("init",arguments)},fetchBids:function(){e("fetchBids",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},que:[]};var n=document.createElement("script");n.async=!0,n.src="https://lib.nexx360.io/nexx360_ortb.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t)}function e(n,t){window.n360ortb.que.push([n,t])}}();
  </script>

  <script>
    // Initialize
    n360ortb.init({
      currency: 'EUR'
    });

    // Fetch bids and render
    n360ortb.fetchBids({
      slots: [
        {
          tagId: 'your-tag-id',
          divId: 'ad-container',
          sizes: [[300, 250]]
        }
      ]
    }, function(bids) {
      // Check if we have a bid for this slot
      var bid = bids['ad-container'];

      if (bid) {
        renderAd('ad-container', bid);
      } else {
        console.log('No bid received');
        // Optionally show fallback content
      }
    });

    function renderAd(divId, bid) {
      var container = document.getElementById(divId);

      // Create an iframe to render the ad
      var iframe = document.createElement('iframe');
      iframe.width = bid.width;
      iframe.height = bid.height;
      iframe.frameBorder = '0';
      iframe.scrolling = 'no';
      iframe.marginWidth = '0';
      iframe.marginHeight = '0';
      iframe.style.border = 'none';

      container.appendChild(iframe);

      // Write the ad markup to the iframe
      var doc = iframe.contentWindow.document;
      doc.open();
      doc.write(bid.adm);
      doc.close();
    }
  </script>
</head>
<body>
  <h1>My Page</h1>

  <div id="ad-container" style="width: 300px; height: 250px;">
    <!-- Ad will render here -->
  </div>
</body>
</html>

Understanding the Bid Response

The fetchBids() callback receives an object with bids keyed by divId:

The adm property contains the complete ad markup (HTML/JavaScript) that should be rendered.

Handling Multiple Slots

Handling No Bids

When no bid is returned for a slot, you can display fallback content:

Safe Rendering with Friendly Iframe

For better isolation and security, render ads in a friendly iframe:

Refreshing Ads

To refresh ads after a period of time:

circle-exclamation

Next Steps

Last updated

Was this helpful?