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 bids as an array

  3. Render ads using n360ortb.renderAd()

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/nexx360ortb/api.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',
          slotID: 'ad-container',
          sizes: [[300, 250]]
        }
      ]
    }, function(bids) {
      // bids is an array of StoredBid objects
      if (bids.length > 0) {
        // Render each bid into its target container
        bids.forEach(function(bid) {
          n360ortb.renderAd(bid, bid.slotID);
        });
      } else {
        console.log('No bids received');
      }
    });
  </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 array of StoredBid objects:

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

The renderAd() Function

n360ortb.renderAd(bid, targetElement) handles rendering with automatic iframe context detection:

Context
Behavior

Main page

Creates an iframe and renders using srcdoc

Friendly iframe

Resizes parent iframe, then renders

SafeFrame

Calls $sf.ext.expand(), then document.write()

Cross-origin iframe

Sends postMessage resize request, then renders

Handling Multiple Slots

Handling No Bids

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

How renderAd() Works

The built-in n360ortb.renderAd() function automatically:

  1. Creates a secure iframe - Ads are isolated in their own document context

  2. Uses srcdoc - Modern, secure way to inject HTML into iframes

  3. Handles resizing - Automatically resizes based on bid dimensions

  4. Detects context - Adapts behavior for SafeFrame, friendly iframe, or cross-origin scenarios

circle-check

Refreshing Ads

To refresh ads after a period of time:

circle-exclamation

Next Steps

Last updated

Was this helpful?