API reference
Device ID integrations
Serve FFraud's Device ID from your own domain on Cloudflare, Vercel, Netlify, nginx or any Node server, so ad blockers have nothing to block.
Ad blockers block scripts and calls to outside addresses they know. Served from your own domain, the Device ID script and its calls look like the rest of your site, so they reach every visitor, and FFraud still sees each visitor's real address. One small relay on your host does it.
#How the relay works
/_d/s.json your domain serves the Device ID script./_d/v1/*forwards the script's calls tohttps://api.ffraud.com/v1/*with two headers:X-FF-Proxy-Secret, your secret key, which proves the relay is yours, andX-FF-Client-IP, the visitor's address.- FFraud accepts the address only when the secret key belongs to the same account as the page's public key, so a forged header never moves an address.
- Your secret key stays in your host's secret store and travels only from your server to FFraud. Your site's cookies stay home: every relay below drops them.
#On your pages
<script src="/_d/s.js"></script>
<script>
FFraudSDK.identify({ apiKey: "pk_your_public_key", baseUrl: "/_d" });
</script>Your public key must list your site under its allowed origins (Dashboard, API keys). The verdict is read from your server with the secret key, as in the Device ID docs.
#Pick your host
// FFraud Device ID relay for Cloudflare Workers.
// Route: yourdomain.com/_d/* Secret: FFRAUD_SECRET_KEY (your secret key, ff_live_...)
const SCRIPT = "https://ffraud.com/api/sdk.js";
const API = "https://api.ffraud.com";
const PREFIX = "/_d";
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === PREFIX + "/s.js") {
return fetch(SCRIPT, { cf: { cacheTtl: 3600, cacheEverything: true } });
}
if (!url.pathname.startsWith(PREFIX + "/v1/")) {
return new Response("Not found", { status: 404 });
}
const headers = new Headers(request.headers);
headers.delete("cookie");
headers.set("x-ff-proxy-secret", env.FFRAUD_SECRET_KEY);
headers.set("x-ff-client-ip", request.headers.get("cf-connecting-ip") || "");
return fetch(API + url.pathname.slice(PREFIX.length) + url.search, {
method: request.method,
headers,
body: request.method === "GET" || request.method === "HEAD" ? undefined : await request.arrayBuffer(),
});
},
};
| Host | Where the code goes | Then |
|---|---|---|
| Cloudflare | worker.js | Create a Worker with this code, add your secret key as the secret FFRAUD_SECRET_KEY, and route yourdomain.com/_d/* to it. Or let the dashboard do all three in one click (Device ID, Setup). |
| Vercel and Next.js | app/%5Fd/[...path]/route.ts | Add this route handler to your Next.js app and FFRAUD_SECRET_KEY to the project's environment variables (Vercel: Settings, Environment Variables), then deploy. |
| Netlify | netlify/edge-functions/ffraud.js | Add this Edge Function and FFRAUD_SECRET_KEY to the site's environment variables (Site configuration, Environment variables), then deploy. |
| Node and Express | ffraud-relay.mjs | Hand /_d/* to ffraudRelay in your server and set FFRAUD_SECRET_KEY in its environment. |
| nginx | nginx.conf | Add these two locations to the server block of your site and reload nginx. |
#Check that it works
- Open your site in a browser with an ad blocker on.
- In the dashboard, Device ID, Identification: the new visit shows the visitor's own address, not your server's.
- An error 2090 (PROXY_SECRET_MISMATCH) means the secret key belongs to another account than the page's public key. An error 2091 (CLIENT_IP_MISSING) means the relay did not send the visitor's address.
Can I use another path than /_d?
Yes. Change PREFIX in the relay and baseUrl on the page to the same path.
Does the relay slow my pages down?
The script keeps its own cache headers (four hours), so a browser loads it once and reuses it; the Cloudflare relay also keeps it at the edge. Each call of the script adds one hop, from your host to FFraud.
Which key goes where?
The public key (pk_...) goes on the page. The secret key (ff_live_...) goes only into your host's secret store, as FFRAUD_SECRET_KEY.