Developers
Analytics you can build into your product.
A TypeScript SDK, an HTTP API described in OpenAPI, and an MCP server. Give every user of your SaaS, website builder or app their own stats, under your brand.
import { createClient } from 'nahnu-analytics-sdk';
const stats = createClient(); // NAHNU_ANALYTICS_URL + NAHNU_ANALYTICS_KEY
// When someone signs up
await stats.clients.upsert(user.id, { name: user.company });
// When they add a website (calling again updates, never doubles)
const { site } = await stats.sites.upsert(website.id, {
name: website.name,
domains: [website.domain],
client: user.id,
currency: 'USD',
});
// "Tracking is working"
const { receiving } = await stats.sites.status(website.id);// app/nq/[file]/route.ts
import { createProxy } from 'nahnu-analytics-sdk/next/server';
export const { GET, POST } = createProxy();
// app/layout.tsx
import { Analytics } from 'nahnu-analytics-sdk/next';
export default async function Layout({ children }) {
const tenant = await tenantForHost();
return (
<html><body>
{children}
{tenant && <Analytics siteKey={tenant.siteKey} />}
</body></html>
);
}import { stripeMetadata, fromStripe } from 'nahnu-analytics-sdk';
// Inside the buyer's request: joins their visit
await stats.track(request, website.id, 'Purchase', {
revenue: { amount: 49, currency: 'USD' },
props: { plan: 'pro' },
});
// In your Stripe webhook
const sale = fromStripe(event); // retried webhooks count once
if (sale) await stats.events.send(sale.site ?? website.id, sale.event);import { createAppClient } from 'nahnu-analytics-sdk/app';
const stats = createAppClient({
siteKey: SITE_KEY,
receiveUrl: RECEIVE_URL,
domain: 'app.janebakery.com',
platform: Platform.OS,
appVersion: '2.1.0',
});
stats.screen('Home');
stats.event('Purchase', { revenue: { amount: 12.5, currency: 'EUR' } });
stats.identify(user.id); // offline events wait and send later// Your server: a short-lived token for this user's sites
const t = await stats.readToken({ client: user.id, ttl: 600 });
// The browser reads straight from Cloudflare. No WordPress hop.
import { createReader } from 'nahnu-analytics-sdk/read';
const reader = createReader({ endpoint: t.endpoint, token: t.token });
await reader.overview(siteId, { period: '30d', compare: 'previous' });
await reader.report(siteId, 'source', { period: '12m' });Build with Nahnu Analytics
Pick where your code runs.
What the SDK does
Deep integration, not a tracking snippet.
Built for SaaS products, website builders and app platforms. Every report and goal works for this data, as for any other site.
- Set everything up from your systemEach user becomes a client and each website a site, by your own IDs.Read the guide →
- Track under your brandScript and visits come from every custom domain your Next.js app serves.Read the guide →
- Record sales from your serversStripe and Shopify webhooks join the buyer’s visit, so the right source gets credit.Read the guide →
- Count screens in your appsReact Native, Expo, or anything that can send HTTP. Works offline.Read the guide →
- Sign users in to their portalA one-time link behind an Analytics button in your app.Read the guide →
- Read stats straight from CloudflareShort-lived read tokens, with no WordPress in the path.Read the guide →
Ways in
Send events from wherever the action happens.
An event becomes a goal when you add one with its name. Funnels work across events and pages.
window.NahnuAnalytics.track('Signup', { props: { plan: 'pro' } })<button data-k-event="Signup" data-k-p-plan="pro">nahnu_analytics_track( 'Lead won', array( 'revenue' => array( 'amount' => 490, 'currency' => 'USD' ) ) );await stats.track(request, site.id, 'Purchase', { revenue })POST /events/{id} Authorization: Bearer nak_…claude mcp add --transport http nahnu https://youragency.com/wp-json/nahnu-analytics/v1/mcp
Production-safe
Stats should never be the reason a checkout fails.
track() never throwsA stats hiccup can’t break a checkout. It returns false and reports to onError.trackAfter()Runs after the response is sent, so pages never wait.Idempotent eventsGive an event an ID and repeats within three days count once.Safe retriesNetwork errors, 429s and 5xx are retried only when nothing can double, honoring Retry-After.Rate-limit headersX-RateLimit-Limit, -Remaining and -Reset on every answer. 20,000 requests an hour.stats.check()Says what’s wrong with the address or key, for health checks.
Fast reads
Dashboards in your app, read straight from Cloudflare.
Your server makes a short-lived read token for the sites a user may see. Reads go to Cloudflare with it: no PHP, no extra hop.
- A token reads only the sites it names, and nothing but reads
- Limit it to your app’s origins; it ends after its TTL (up to 7 days)
- Renewed a minute before it ends; rotate the secret to revoke them all
stats.readToken()createReader()overview · report · funnelWordPress is not in the read path
AI agents
Ask Claude, ChatGPT or Cursor about every website.
A read-only MCP server. Connect with a click and sign in to WordPress: there is no key to copy. Nothing can be changed through it.
Ready-made prompts: a weekly summary, which websites grew, an SEO check-up, AI assistants, and conversions.
$ claude mcp add --transport http nahnu \
https://youragency.com/wp-json/nahnu-analytics/v1/mcp17 read-only tools
- list_sites
- compare_sites
- get_stats
- get_report
- get_realtime
- get_goals
- get_funnel
- get_journey
- get_conversions
- get_site_health
- get_retention
- get_feedback
- get_search
- get_indexing
- get_seo
- get_ai_visibility
- get_site_audit
HTTP API
Any language. Described in OpenAPI.
Authenticate with a platform key from Data and API › API keys. The spec ships in the package as openapi.json, and an API playground is built into wp-admin.
- PUT
/platform/clients/{ref} - PUT
/platform/sites/{ref} - GET
/platform/sites/{ref}/status - POST
/platform/clients/{ref}/login - POST
/platform/sites/{ref}/embed - PUT
/platform/sites/{ref}/links - GET
/platform/usage - POST
/events/{id} - GET
/stats/{id} - GET
/stats/{id}/report - GET
/realtime/{id} - POST
/sites/{id}/goals
Guides
Step by step, from install to dashboards.
The SDK, API and MCP come with every license.
Unlimited websites. The SDK is on npm, GPL-licensed.