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.
<!-- 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:
<!-- 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
| Attribute | Required | Description | Example |
|---|---|---|---|
data-zone-id | Yes | Zone ID | 3887fe9a |
data-width | No | Ad width (overrides CSS width) | 300 |
data-height | No | Ad height (overrides CSS height) | 250 |
data-lazy | No | Whether to lazy-load, default true | true / 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:
<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>| Option | Type | Default | Description |
|---|---|---|---|
debug | boolean | false | Enable debug logging |
apiUrl | string | https://ad.adbnk.co | Ad request endpoint |
timeout | number | 10000 | Request 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):
| Type | Description |
|---|---|
BANNER | Image banner, supports various standard sizes |
NATIVE | Native ad blended with page content |
VIDEO | Video ad (muted autoplay by default) |
RICH_MEDIA | Template-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
// Refresh a specific zone (re-request and render)
window.adbnk.refresh('3887fe9a');Manually add a zone
For dynamically generated containers, register them with push:
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:
<!-- 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
| Change | v2 | v3 |
|---|---|---|
| Container tag | <div data-adbnk-zone="zone_xxx"> | <ins class="adsbyadbnk" data-zone-id="xxx"> |
| Script | async.js + ADBNK_CONFIG | sdk.js (no ADBNK_CONFIG) |
| Rendering | Client-side rendering | Server returns rendered HTML |
Troubleshooting
If an ad doesn't show, check in order:
- Is
data-zone-idcorrect and the zone enabled? - Did
sdk.jsload successfully (confirmjs.adbnk.co/sdk.jsreturns 200 in the Network panel)? - Does the container have a valid width and height?
- Enable debug mode and check the console
[ADBNK]logs:
<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.