Publisher SDK

IdleFlow shows a small sponsored card only while your AI app is loading, streaming, or thinking. An impression is billable only after five seconds of focused, visible display. Publishers keep 70% of verified revenue.

1. Create a publisher app

Sign in at /publisher.html, register your app, verify the domain, and run automatic loading-state detection. If your app requires sign-in, use the manual busy API below.

2. Add the tag

production tag
<script async
  src="https://YOUR_DOMAIN/sdk/publisher.js"
  data-publisher-id="pub_yourid"
  data-app-id="app_yourapp">
</script>

3. Manual loading control

Use this when your app has custom loading state, authenticated views, or client-side transitions that a crawler cannot detect reliably.

manual API
window.idleflow.signalBusy(true);   // model started thinking
window.idleflow.signalBusy(false);  // response finished

4. Test mode

Test mode renders a local test ad, logs SDK diagnostics, and never sends billing events.

test tag
<script async
  src="/sdk/publisher.js"
  data-publisher-id="test"
  data-mode="test">
</script>

Use the hosted SDK test page to verify that the card appears and the manual busy API behaves correctly.

5. Optional audience attributes

Only send coarse first-party bands with user consent. The server validates these values and rejects PII-shaped data.

coarse attributes
window.idleflow.setUserAttributes({
  ageBand: "25-34",
  gender: "other",
  interests: ["developer-tools", "ai-coding"]
});

6. Events for your analytics

The SDK emits browser events you can listen to without touching billing logic.

custom events
window.addEventListener("idleflow:adShown", (e) => console.log(e.detail));
window.addEventListener("idleflow:impression", (e) => console.log(e.detail));
window.addEventListener("idleflow:click", (e) => console.log(e.detail));
Launch checklist