Count visitors with ad blockers
Load Okidoki from your own address, so ad blockers let it through. Same data, no cookies.
Some ad blockers stop analytics by its address. They see a script from okidoki.sh and block it, without looking at what it does. Load the same script from your own address instead and they let it through, so visitors who use an ad blocker are counted too.
Nothing else changes. Okidoki still sets no cookies, never keeps an IP address and has no visitor IDs. Your site's own cookies stay behind too: the script sends visits without them, and the recipes below never pass them on. Your privacy policy line still names Okidoki. Only the address the script loads from is different.
There are two ways. Both are free, on every plan.
| Own subdomain | Proxy | |
|---|---|---|
| What you do | Add one DNS record | Your builder or agent adds a small forwarding function to the site |
| Needs | Your own domain, like mysite.com | A site where the server or hosting config can be changed |
| Countries | Exactly as before | Passed on by the proxy, or shown as unknown |
| Good for | Lovable, Framer, Webflow, Wix, Squarespace and any site with its own domain | Next.js, Vercel, Netlify, Cloudflare and Node, also on addresses like myapp.vercel.app |
#Own subdomain
- Open Settings → Site and find Count visitors with ad blockers. Okidoki suggests a subdomain, like
x7f3k.mysite.com. The name is made from your site key, so no ad block list has a rule for it. Keep it, or pick your own. - Click Use this subdomain. Okidoki shows one DNS record to add, a CNAME.
- If your domain is at a provider that supports Domain Connect, like Cloudflare, GoDaddy or IONOS, there is a button that adds it for you. You sign in at your provider and approve that one record. Nothing else on your domain changes, and Okidoki never sees your login.
- Otherwise Okidoki recognises your provider, like Loopia, Namecheap or one.com, and shows where in their settings to add it.
- When the record works, usually within minutes, Okidoki says the subdomain is ready and shows a new line for your pages:
<script defer crossorigin="anonymous" data-site="ok_x7f3k2abcd" src="https://x7f3k.mysite.com/s.js"></script>- Put it in the head of every page instead of the old line, or paste it to your builder: Change the Okidoki script tag on every page to followed by the line.
The subdomain serves the Okidoki script and receives the visits, and nothing else. Okidoki never changes your DNS by itself: you approve the record at your provider, or add it yourself.
#Proxy
Your site forwards a few addresses to Okidoki: the script, the add-ons it loads next to itself, and the place visits are sent to. It uses a small function rather than a plain rewrite, because a rewrite would pass on your visitors' cookies. The function passes on only the browser type, its language and the Global Privacy Control signal. Each site gets its own short path, like /x7f3k, shown in Settings. Paste this to your builder or coding agent, with your own path filled in:
Make Okidoki Analytics on my site mysite.com count visitors who use ad blockers, by serving it from the site's own address. With a small server function (not in the browser, and not a plain rewrite, since a rewrite passes on the visitor's cookies), forward GET /x7f3k/s.js to https://okidoki.sh/js/okidoki.js, GET /x7f3k/v.js to https://okidoki.sh/js/v.js (the video add-on), GET /x7f3k/f.js to https://okidoki.sh/js/f.js with its query string (the forms add-on) and POST /x7f3k/e to https://okidoki.sh/api/event?via=proxy. Pass on the request body as it is and only the User-Agent, Accept-Language and Sec-GPC headers: never the Cookie header, and send back the files without any Set-Cookie. If the host knows the visitor's country (like the x-vercel-ip-country or cf-ipcountry header, or Netlify context.geo), add it as &country=XX with the two-letter code. Never forward the visitor's IP address. Then change the Okidoki script tag to: <script defer data-site="ok_x7f3k2abcd" src="/x7f3k/s.js"></script> Recipes for Next.js, Vercel, Netlify, Cloudflare and Node: https://docs.okidoki.sh/ad-blockers. Do not change anything else. When you are done, publish or deploy the change. If you cannot, tell me exactly how I publish it. This does not change what Okidoki collects: still no cookies, no IP addresses and no visitor IDs, and it is still named in the privacy policy line.
The new line for your pages then is:
<script defer data-site="ok_x7f3k2abcd" src="/x7f3k/s.js"></script>#Next.js
A route handler in the App Router. If your site uses its own middleware that sets cookies, leave this path out of it.
// A route handler, not a rewrite: a rewrite would pass on the visitor's cookies.
const scripts = { 's.js': '/js/okidoki.js', 'v.js': '/js/v.js', 'f.js': '/js/f.js' };
export async function GET(request, { params }) {
const url = new URL(request.url);
const file = (await params).file;
if (!scripts[file]) return new Response(null, { status: 404 });
// The forms add-on needs its query string (?k=...).
return new Response((await fetch('https://okidoki.sh' + scripts[file] + (file === 'f.js' ? url.search : ''), { next: { revalidate: 3600 } })).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
}
export async function POST(request, { params }) {
if ((await params).file !== 'e') return new Response(null, { status: 404 });
const h = request.headers;
// On Vercel: the visitor's country, never the IP address.
const country = h.get('x-vercel-ip-country');
await fetch('https://okidoki.sh/api/event?via=proxy' + (country ? '&country=' + country : ''), {
method: 'POST',
body: await request.text(),
// Only these headers. Never the visitor's cookies or IP address.
headers: { 'content-type': 'text/plain', 'user-agent': h.get('user-agent') ?? '', 'accept-language': h.get('accept-language') ?? '', 'sec-gpc': h.get('sec-gpc') ?? '' },
}).catch(() => {});
return new Response(null, { status: 202 });
}#Vercel without Next.js
Rewrite the path to a function in api/, which forwards it without cookies.
// vercel.json: send the paths to the function below, not straight to Okidoki,
// since a rewrite to another domain would pass on the visitor's cookies.
{
"rewrites": [{ "source": "/x7f3k/:file", "destination": "/api/okidoki?file=:file" }]
}
// api/okidoki.mjs
const scripts = { 's.js': '/js/okidoki.js', 'v.js': '/js/v.js', 'f.js': '/js/f.js' };
export async function GET(request) {
const url = new URL(request.url);
const file = url.searchParams.get('file');
if (!scripts[file]) return new Response(null, { status: 404 });
// The forms add-on needs its query string (?k=...).
return new Response((await fetch('https://okidoki.sh' + scripts[file] + (file === 'f.js' ? '?k=' + url.searchParams.get('k') : ''))).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
}
export async function POST(request) {
const url = new URL(request.url);
if (url.searchParams.get('file') !== 'e') return new Response(null, { status: 404 });
const h = request.headers;
// On Vercel: the visitor's country, never the IP address.
const country = h.get('x-vercel-ip-country');
await fetch('https://okidoki.sh/api/event?via=proxy' + (country ? '&country=' + country : ''), {
method: 'POST',
body: await request.text(),
// Only these headers. Never the visitor's cookies or IP address.
headers: { 'content-type': 'text/plain', 'user-agent': h.get('user-agent') ?? '', 'accept-language': h.get('accept-language') ?? '', 'sec-gpc': h.get('sec-gpc') ?? '' },
}).catch(() => {});
return new Response(null, { status: 202 });
}#Netlify
export default async (request, context) => {
const url = new URL(request.url);
const file = url.pathname.split('/').pop();
// The script, or the video or forms add-on next to it.
if (request.method === 'GET') {
return new Response((await fetch(file === 'v.js' ? 'https://okidoki.sh/js/v.js' : file === 'f.js' ? 'https://okidoki.sh/js/f.js' + url.search : 'https://okidoki.sh/js/okidoki.js')).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
}
const h = request.headers;
const country = context.geo?.country?.code;
await fetch('https://okidoki.sh/api/event?via=proxy' + (country ? '&country=' + country : ''), {
method: 'POST',
body: await request.text(),
// Only these headers. Never the visitor's cookies or IP address.
headers: { 'content-type': 'text/plain', 'user-agent': h.get('user-agent') ?? '', 'accept-language': h.get('accept-language') ?? '', 'sec-gpc': h.get('sec-gpc') ?? '' },
}).catch(() => {});
return new Response(null, { status: 202 });
};
export const config = { path: ['/x7f3k/s.js', '/x7f3k/v.js', '/x7f3k/f.js', '/x7f3k/e'] };#Cloudflare
Add a Worker on the route mysite.com/x7f3k/*.
export default {
async fetch(request) {
const { pathname, search } = new URL(request.url);
if (pathname === '/x7f3k/s.js') return new Response((await fetch('https://okidoki.sh/js/okidoki.js')).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
if (pathname === '/x7f3k/v.js') return new Response((await fetch('https://okidoki.sh/js/v.js')).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
if (pathname === '/x7f3k/f.js') return new Response((await fetch('https://okidoki.sh/js/f.js' + search)).body, { headers: { 'content-type': 'application/javascript', 'cache-control': 'public, max-age=3600' } });
if (pathname !== '/x7f3k/e' || request.method !== 'POST') return new Response(null, { status: 404 });
const h = request.headers;
const country = request.cf?.country;
await fetch('https://okidoki.sh/api/event?via=proxy' + (country ? '&country=' + country : ''), {
method: 'POST',
body: await request.text(),
// Only these headers. Never the visitor's cookies or IP address.
headers: { 'content-type': 'text/plain', 'user-agent': h.get('user-agent') ?? '', 'accept-language': h.get('accept-language') ?? '', 'sec-gpc': h.get('sec-gpc') ?? '' },
}).catch(() => {});
return new Response(null, { status: 202 });
},
};#Node and Express
// Put these before any session or cookie middleware, so no cookie is set on these paths.
// The script, and the add-ons it loads on pages with a video or a form.
app.get(['/x7f3k/s.js', '/x7f3k/v.js', '/x7f3k/f.js'], async (req, res) => {
const query = req.originalUrl.includes('?') ? req.originalUrl.slice(req.originalUrl.indexOf('?')) : '';
const file = req.path.endsWith('/v.js') ? '/js/v.js' : req.path.endsWith('/f.js') ? '/js/f.js' + query : '/js/okidoki.js';
const script = await fetch('https://okidoki.sh' + file);
res.type('application/javascript').set('Cache-Control', 'public, max-age=3600').send(await script.text());
});
app.post('/x7f3k/e', express.text({ type: '*/*' }), async (req, res) => {
const h = { get: (name) => req.get(name) };
// Behind Cloudflare the country is known; otherwise Okidoki shows it as unknown.
const country = req.get('cf-ipcountry');
await fetch('https://okidoki.sh/api/event?via=proxy' + (country ? '&country=' + country : ''), {
method: 'POST',
body: req.body,
// Only these headers. Never the visitor's cookies or IP address.
headers: { 'content-type': 'text/plain', 'user-agent': h.get('user-agent') ?? '', 'accept-language': h.get('accept-language') ?? '', 'sec-gpc': h.get('sec-gpc') ?? '' },
}).catch(() => {});
res.status(202).end();
});#Countries through a proxy
Okidoki normally learns the visitor's country from where the request comes from. Through a proxy, every request comes from your server, so that would be wrong. The recipes above pass on only the country your host already knows, as two letters. If your host does not know it, the country is shown as unknown. A proxy never forwards the visitor's IP address, and Okidoki would not keep it anyway.
#With an agent
An agent connected to Okidoki can do all of this. It calls get_ad_blocker_setup in the MCP server, or GET /api/v1/sites/mysite.com/ad-blockers in the API, and gets the suggested subdomain, the DNS record, the proxy sentence and the recipes. set_own_subdomain adds the subdomain. If the agent can manage your DNS, it adds the record too and checks again until the subdomain is ready.
#Is this fair to visitors?
People use ad blockers to stop ads and to avoid being followed from site to site. Okidoki shows no ads and cannot follow anyone: it has no cookies, no IDs and nothing that links one page view to the next. Loading it from your own address does not change any of that. It only means the count is right. See Privacy and GDPR for everything Okidoki collects.