Skip to content

JS Ad SDK

The ADBNK Ad SDK (v3) offers an AdSense-style, minimal integration: place an ad-zone container tag on the page and include one line of SDK script to auto-load ads. The SDK automatically scans zones, extracts page targeting info, lazy-loads, and renders ads safely in a sandboxed iframe.

Three domains, each with a role

  • https://js.adbnk.co — SDK script distribution (sdk.js)
  • https://ad.adbnk.co — ad request endpoint (/ad/request)
  • https://track.adbnk.co — impression / click / conversion tracking

Quick start

Minimal integration takes two steps: place the zone container + include the SDK.

html
<!-- 1. Place an ad-zone container where you want the ad to show -->
<ins class="adsbyadbnk"
     data-zone-id="3887fe9a"
     style="display:block;width:300px;height:250px;">
</ins>

<!-- 2. Include the SDK at the bottom of the page (before </body>) -->
<script async src="https://js.adbnk.co/sdk.js"></script>

Once included, the SDK automatically:

  • Scans all <ins class="adsbyadbnk"> zone elements on the page
  • Extracts page meta / Open Graph / JSON-LD info for ad targeting
  • Lazy-loads ads (requesting only when the element enters the viewport)
  • Renders ads in a sandboxed iframe, isolating and protecting the host page

Here data-zone-id is the zone ID; get it after creating a zone in the publisher console.

Ad-zone container

Supported tag formats

The <ins> tag is recommended; <div> and legacy attributes are also supported:

html
<!-- Recommended: ins tag + class -->
<ins class="adsbyadbnk" data-zone-id="xxx" style="display:block;width:300px;height:250px;"></ins>

<!-- Also supported: div tag -->
<div class="adsbyadbnk" data-zone-id="xxx" style="width:300px;height:250px;"></div>

<!-- Legacy attribute compatibility -->
<div data-adbnk-zone="zone_xxx"></div>

Zone attributes

AttributeRequiredDescriptionExample
data-zone-idYesZone ID3887fe9a
data-widthNoAd width (overrides CSS width)300
data-heightNoAd height (overrides CSS height)250
data-lazyNoWhether to lazy-load, default truetrue / false

Always set a size on the container

The zone needs an explicit width and height (via style or data-width/data-height). Otherwise lazy loading may fail to judge the viewport because the height is 0, and the ad won't load.

Initialization options

To customize global behavior, declare the window.adbnk config object before including sdk.js:

html
<script>
  window.adbnk = {
    debug: false,                     // when on, logs [ADBNK]-prefixed debug output to the console
    apiUrl: 'https://ad.adbnk.co',    // ad request endpoint
    timeout: 10000                    // per-request timeout (ms)
  };
</script>
<script async src="https://js.adbnk.co/sdk.js"></script>
OptionTypeDefaultDescription
debugbooleanfalseEnable debug logging
apiUrlstringhttps://ad.adbnk.coAd request endpoint
timeoutnumber10000Request timeout (ms)

Rendering and ad types

After the SDK requests https://ad.adbnk.co/ad/request, the server returns fully rendered HTML, which the SDK injects into a sandboxed iframe. The impression and click tracking URLs are built into the returned HTML, so no extra frontend handling is needed. See Ad Request API for the full request parameters.

Supported ad types (determined by the zone type and creative; the frontend doesn't need to distinguish):

TypeDescription
BANNERImage banner, supports various standard sizes
NATIVENative ad blended with page content
VIDEOVideo ad (muted autoplay by default)
RICH_MEDIATemplate-based interactive rich-media ad

Common sizes: 300x250 (medium rectangle), 728x90 (leaderboard), 320x50 (mobile banner), 300x600 (half-page), 970x250 (billboard). See Ad Formats for more.

JavaScript API

After loading, the SDK mounts methods on window.adbnk to manually control zones (e.g. SPA route changes, infinite-scroll dynamic insertion).

Manually refresh an ad

js
// Refresh a specific zone (re-request and render)
window.adbnk.refresh('3887fe9a');

Manually add a zone

For dynamically generated containers, register them with push:

js
window.adbnk.push({
  zoneId: '3887fe9a',
  container: '#ad-container'
  // or pass the element directly: element: document.getElementById('ad-container')
});

Tracking is built in

Impression and click tracking logic is already built into the server-rendered ad HTML and reported automatically via track.adbnk.co — no manual instrumentation needed. To report conversions, see Conversion Tracking SDK.

Page targeting info

The SDK automatically extracts the following from the page and sends it with the ad request to improve relevance; you don't need to pass anything manually:

html
<!-- Open Graph -->
<meta property="og:title" content="Article title">
<meta property="og:type" content="article">

<!-- Standard meta -->
<meta name="keywords" content="keyword1, keyword2">
<meta name="description" content="Page description">

<!-- JSON-LD structured data -->
<script type="application/ld+json">
{ "@context": "https://schema.org", "@type": "Article",
  "headline": "Article title", "keywords": ["AI", "Machine Learning"] }
</script>

The device fingerprint is collected automatically using the open-source FingerprintJS v4 — no manual setup needed.

Migrating from v2

Changev2v3
Container tag<div data-adbnk-zone="zone_xxx"><ins class="adsbyadbnk" data-zone-id="xxx">
Scriptasync.js + ADBNK_CONFIGsdk.js (no ADBNK_CONFIG)
RenderingClient-side renderingServer returns rendered HTML

Troubleshooting

If an ad doesn't show, check in order:

  1. Is data-zone-id correct and the zone enabled?
  2. Did sdk.js load successfully (confirm js.adbnk.co/sdk.js returns 200 in the Network panel)?
  3. Does the container have a valid width and height?
  4. Enable debug mode and check the console [ADBNK] logs:
html
<script>window.adbnk = { debug: true };</script>
<script async src="https://js.adbnk.co/sdk.js"></script>

Security note

All ads render in a sandbox iframe, restricted to allow-scripts allow-popups, so ad code can't access the host page's DOM or cookies.

Documentation released under the MIT License.