Add ads to your site
Two steps: place slots where ads should appear, then connect your site the way it is built. Signed in, the same guide is under Sites › Set up ads, with your site's key and a page check.
Place slots where ads should appear
A slot is an empty element. Put one wherever an ad should go, and give each place its own name (it shows up in your reports). Make the code for a slot here:
HTML (any site):
<div data-net-slot="sidebar"></div>
WordPress shortcode:
[net_slot name="sidebar" format="text"]
React, Next.js and similar (with the AdSlot component below):
<AdSlot name="sidebar" format="text" />
Not sure which format? Use text: it fits any space and adapts to phones. A fixed size with no image ad of that size shows a text ad in the same space. See every format. At most 12 slots are filled per page, and one sticky bar.
The ad takes the full width of the slot and picks light or dark colours from the page behind it. You can match your site's colours exactly under Appearance.
Connect your site
Pick how your site is built. The first four keep everything on your own domain, so content blockers mostly leave the ads alone; the plain script tag is the quickest to add.
WordPress plugin, nothing to code
Needs a site key. Make a site key in your dashboard, next to the site. It is shown only once.
- Download the plugin (zip), then in WordPress go to Plugins › Add New › Upload Plugin, choose the zip and activate it.
- Go to Settings › Network Slots, paste your site key and save.
- If your site is behind Cloudflare, tick read the visitor's address from CF-Connecting-IP.
- Go to Settings › Permalinks and press Save once, so WordPress picks up the
/p/address. - Add slots with the shortcode, the Network slot block, or the Network slot widget.
Caching plugins: exclude pages with slots from full-page caching (WP Rocket, W3 Total Cache, LiteSpeed and others), or every visitor gets the same ad and views stop counting. More about the plugin.
Cloudflare Workers fills slots on Cloudflare's edge
Needs a site key. Make a site key in your dashboard, next to the site. It is shown only once.
- Store the key as a secret:
npx wrangler secret put NET_KEY - Put this Worker in front of your site (or merge it into the Worker you have). If the Worker serves your files itself, use
env.ASSETS.fetch(request)where it says so. - Add slots to your pages. The Worker fills them and passes views and visits through
/p/.
// Cloudflare Worker in front of your site. Store the site key as the secret NET_KEY: // npx wrangler secret put NET_KEY const NET = "https://ads.brinktale.com"; const SLOT = "[data-net-slot]"; export default { async fetch(request, env) { const url = new URL(request.url); // Views and visits travel through your own domain. Pass the visitor's own details on: // a view or a visit counts only if it comes from the visitor the ad was served to. if (url.pathname.startsWith("/p/")) { if (request.method !== "GET") return new Response(null, { status: 405 }); const headers = { Authorization: "Bearer " + env.NET_KEY, "X-Visitor-IP": request.headers.get("CF-Connecting-IP") || "", "X-Visitor-ASN": String(request.cf?.asn || ""), }; for (const name of ["Referer", "User-Agent", "Accept-Language", "Sec-Fetch-Site", "Sec-Fetch-Mode", "Sec-Fetch-Dest"]) { if (request.headers.get(name)) headers[name] = request.headers.get(name); } return fetch(NET + url.pathname + url.search, { headers, redirect: "manual" }); } const response = await fetch(request); // or: await env.ASSETS.fetch(request) if (!(response.headers.get("Content-Type") || "").includes("text/html")) return response; // 1. Find the slots on this page. const slots = []; await new HTMLRewriter() .on(SLOT, { element(el) { slots.push({ name: el.getAttribute("data-net-slot"), format: el.getAttribute("data-net-format") || "text" }); } }) .transform(response.clone()).arrayBuffer(); if (!slots.length) return response; // 2. Ask the network once for all of them. On any failure the page goes out unchanged. const filled = await fetch(NET + "/p/render", { method: "POST", headers: { Authorization: "Bearer " + env.NET_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ slots, page: request.url, ua: request.headers.get("User-Agent"), ip: request.headers.get("CF-Connecting-IP"), prefix: "/p/", }), signal: AbortSignal.timeout(1500), }).then((r) => (r.ok ? r.json() : null)).catch(() => null); if (!filled) return response; // 3. Write the markup into the page. Do not cache the result: every visit gets a fresh pick. let i = 0; const page = new HTMLRewriter() .on(SLOT, { element(el) { const html = filled.slots[i++]?.html; if (html) el.setInnerContent(html, { html: true }); } }) .transform(response); const out = new Response(page.body, page); out.headers.set("Cache-Control", "private, no-store"); out.headers.delete("ETag"); return out; }, };Add the script once per page; it reports a view when an ad has been on screen for a second:
<script defer src="/p/kit.js"></script>
Node.js server Express, Fastify, Koa, plain node:http
Needs a site key. Make a site key in your dashboard, next to the site. It is shown only once.
- Save this as
net-slots.mjsnext to your server code, and set the environment variableNET_KEYto your site key. - Send every
GET /p/*tonetProxy, and pass each page's HTML throughnetFillbefore sending it. - Send
Cache-Control: private, no-storeon pages with slots, and add the script once per page.
// net-slots.mjs (Node.js 18 or later, no dependencies). Works with Express, Fastify, Koa or plain node:http. // Keep the site key on the server, for example in the environment variable NET_KEY. const NET = "https://ads.brinktale.com"; const KEY = process.env.NET_KEY; const SLOT = /<div\b([^>]*\bdata-net-slot="[^"]+"[^>]*)><\/div>/g; // The visitor's own address. Behind a CDN or load balancer, read the header it sets instead. function visitor(req) { return String(req.headers["cf-connecting-ip"] || req.socket.remoteAddress || "").replace(/^::ffff:/, ""); } /** Forward a GET under /p/ to the network. Use it for every request whose path starts with /p/. */ export async function netProxy(req, res) { if (req.method !== "GET") { res.statusCode = 405; return res.end(); } const headers = { Authorization: "Bearer " + KEY, "X-Visitor-IP": visitor(req) }; for (const name of ["referer", "user-agent", "accept-language", "sec-fetch-site", "sec-fetch-mode", "sec-fetch-dest"]) { if (req.headers[name]) headers[name] = req.headers[name]; } const up = await fetch(NET + (req.originalUrl || req.url), { headers, redirect: "manual" }).catch(() => null); if (!up) { res.statusCode = 502; return res.end(); } res.statusCode = up.status; for (const name of ["content-type", "cache-control", "location"]) { if (up.headers.get(name)) res.setHeader(name, up.headers.get(name)); } res.end(Buffer.from(await up.arrayBuffer())); } /** Fill the slots in a page before sending it. On any failure the HTML comes back unchanged. */ export async function netFill(html, req) { const found = [...html.matchAll(SLOT)]; if (!found.length) return html; const slots = found.map((m) => ({ name: /data-net-slot="([^"]+)"/.exec(m[1])[1], format: (/data-net-format="([^"]+)"/.exec(m[1]) || [])[1] || "text", })); const filled = await fetch(NET + "/p/render", { method: "POST", headers: { Authorization: "Bearer " + KEY, "Content-Type": "application/json" }, body: JSON.stringify({ slots, page: "https://" + req.headers.host + (req.originalUrl || req.url), ua: req.headers["user-agent"] || "", ip: visitor(req), prefix: "/p/", }), signal: AbortSignal.timeout(1500), }).then((r) => (r.ok ? r.json() : null)).catch(() => null); if (!filled) return html; let i = 0; return html.replace(SLOT, (whole, attrs) => "<div" + attrs + ">" + (filled.slots[i++]?.html || "") + "</div>"); }With Express:
import express from "express"; import { netProxy, netFill } from "./net-slots.mjs"; const app = express(); app.get("/p/*", netProxy); // Express 5: app.get("/p/*path", netProxy) app.get("/", async (req, res) => { const html = renderHomePage(); // however you build the page now res.set("Cache-Control", "private, no-store"); // every visit gets its own pick res.type("html").send(await netFill(html, req)); });<script defer src="/p/kit.js"></script>
Your own web server nginx, Apache or Caddy forwards one path
Needs a site key. Make a site key in your dashboard, next to the site. It is shown only once.
No code changes: forward
/p/on your site to the network, adding the key and the visitor's address. Then add the script and your slots.# nginx: inside the server { } block of your site location /p/ { proxy_pass https://ads.brinktale.com/p/; proxy_set_header Host ads.brinktale.com; proxy_ssl_server_name on; proxy_set_header Authorization "Bearer <site key>"; proxy_set_header X-Visitor-IP $remote_addr; proxy_redirect off; }# Apache: in the site's <VirtualHost>, with mod_proxy, mod_proxy_http and mod_headers enabled SSLProxyEngine on ProxyPass "/p/" "https://ads.brinktale.com/p/" ProxyPassReverse "/p/" "https://ads.brinktale.com/p/" <Location "/p/"> RequestHeader set Authorization "Bearer <site key>" RequestHeader set X-Visitor-IP "expr=%{REMOTE_ADDR}" </Location># Caddy: inside your site's block in the Caddyfile handle /p/* { reverse_proxy https://ads.brinktale.com { header_up Host {upstream_hostport} header_up Authorization "Bearer <site key>" header_up X-Visitor-IP {remote_host} } }Replace
<site key>with your key. Keep it in the server configuration; never put it in a page. Then add once per page:<script async src="/p/kit.js"></script>
Behind a CDN or load balancer, send the visitor's real address as
X-Visitor-IP(for example fromCF-Connecting-IPorX-Forwarded-For), not the CDN's.Other server languages PHP, Python, Ruby, Go, Java
Needs a site key. Make a site key in your dashboard, next to the site. It is shown only once.
While your server builds a page, ask the network for all its slots in one request, and put each answer's
htmlinside its slot element exactly as it comes. If the network does not answer within about 1.5 seconds, send the page with empty slots.POST https://ads.brinktale.com/p/render Authorization: Bearer <site key> Content-Type: application/json { "slots": [{ "name": "sidebar", "format": "text" }, { "name": "article-end", "format": "native" }], "page": "https://your-site.example/the/page", "ua": "<the visitor's User-Agent header>", "ip": "<the visitor's IP address>", "prefix": "/p/" }The answer has one entry per slot, in the same order. An empty
htmlmeans no ad for that slot this time:{ "slots": [ { "name": "sidebar", "html": "<template shadowrootmode=\"open\">…</template>…", "unit": { "title": "…", "body": "…", "cta": "…", "link": "/p/go?k=…", "view": "/p/seen?k=…", "report": "/p/report?k=…", "image": "" } }, { "name": "article-end", "html": "", "unit": null } ] }Building your own markup from
unitinstead is allowed if it keeps the "Sponsored" label and the report link. Theipanduayou send are what the ad is bound to: its view and visit count only from that same visitor.Then forward
GET /p/*on your site tohttps://ads.brinktale.com/p/*without following redirects, addingAuthorization: Bearer <site key>andX-Visitor-IP, and passing on the visitor'sUser-Agent,Accept-Language,RefererandSec-Fetch-*headers (the nginx, Apache and Caddy examples above do exactly this). SendCache-Control: private, no-storeon filled pages, and add the script once per page:<script defer src="/p/kit.js"></script>
React, Next.js, Vue, Svelte single-page apps
No site key needed.
Add the script once, in your root layout or
index.html. It fills every slot on the page, including slots that appear later when the visitor changes route.<script async src="https://ads.brinktale.com/p/kit.js"></script>
Then render slots as empty elements:
// A slot is an empty element. The script fills it, including slots that appear after a route change. export function AdSlot({ name, format = "text" }) { return <div data-net-slot={name} data-net-format={format} />; } // Use it anywhere, with a different name for each place: <AdSlot name="article-end" format="native" />Next.js: put the script in
app/layoutwith<Script src="https://ads.brinktale.com/p/kit.js" strategy="afterInteractive" />. If you render slots yourself and want them filled at once, callwindow.netSlots.fill(). To keep requests on your own domain, forward/p/as in "Your own web server" and load/p/kit.jsinstead.Any other site plain HTML, static site builders, Blogger, Shopify, Ghost, Webflow, Squarespace
No site key needed.
Paste this once per page, before
</body>or in your platform's "custom code" or "footer code" setting, then add slots in an HTML or embed block:<script async src="https://ads.brinktale.com/p/kit.js"></script>
Works on static sites (GitHub Pages, Netlify, Vercel, Hugo, Jekyll, Astro) and on any builder that puts your HTML straight into the page. It does not work where custom code runs inside a separate frame (Wix's "Embed HTML", for example). Content blockers stop this method more often than the others.
If your site sends a Content-Security-Policy, add:
script-src https://ads.brinktale.com; connect-src https://ads.brinktale.com; img-src https://ads.brinktale.com;
Your domain for all of these:
your-site.exampleand its subdomains.Check it
In your dashboard, open Sites › Set up ads next to your site and use Check a page: it reads one of your pages and lists what works and what to fix.
If something is not right
- Slots stay empty
- The site must be verified and approved. With a first-party method, check that
/p/kit.json your site loads (open it in a browser) and that the forwarding adds your site key. "Check a page" tests all of this. - Ads appear but views do not count
- Views count only from the visitor the ad was served to, after it has been on screen for a second. Pass the visitor's real address (
X-Visitor-IP), and do not cache pages with filled slots. - A slot is too narrow or collapses
- The ad takes the slot's width. In a flex row or grid, give the slot a width (for example
style="flex:1"or a grid cell). Text and native ads adapt to any width; fixed sizes shrink to fit. - The ad does not match my colours
- By default it picks light or dark colours from the page behind it. For exact colours, font and corners, open Appearance next to your site.
- My theme hides empty slots
- Fine: a rule such as
.slot:has(> div:empty){display:none}keeps hiding unfilled slots and leaves filled ones visible. - Strict Content-Security-Policy
- The first-party methods need only
'self'. Inline styles may stay forbidden: the script applies the ad's styles in a way the policy allows.