Node.js, sales from your server.
Record purchases and signups from route handlers, cron jobs and Stripe or Shopify webhooks. Sent from inside the buyer’s request, each one joins their visit, so the source that brought them gets the credit.
await stats.track(request, website.id, 'Purchase', {
revenue: { amount: 49, currency: 'USD' },
props: { plan: 'pro' },
});Illustration
At a glance
Server events, joined to the visit.
What changes when your server uses the SDK.
Credit to the source
Sales from the buyer’s request join their visit.
Never throws
A stats hiccup can’t break a checkout or a signup.
Counted once
The same event id within three days counts once.
Any runtime
Node 18 or later, Deno, Bun and edge runtimes.
Ways to send
Send from anywhere on your server.
From the nahnu-analytics-sdk package.
Where it shows
Where you see it.
Server events count with the browser’s.
Revenue
Purchases and renewals with their amounts.
Goals
Add a goal with the event’s name.
Sources
The source that brought the buyer gets the credit.
Funnels
Across server events and pages.
Your clients’ sites
One platform key works for all clients.
Health check
stats.check() says what is wrong, if anything.
Install
One package, two environment variables.
Install the package, make a platform key in wp-admin under Nahnu Analytics › Data & API › API keys, and set two environment variables.
- A platform key works for all clients
- 20,000 requests an hour
- Keep the key on your server only
NAHNU_ANALYTICS_URL=https://stats.example.com
NAHNU_ANALYTICS_KEY=nak_…Webhooks
A sale sent twice is still one sale.
Give every event an id, such as your order number or a webhook’s event id. A webhook sent again is then not a second sale, and the SDK can safely retry it.
- fromStripe and fromShopify set the id for you
- Stripe amounts are converted from cents for each currency
- Without the buyer’s address a sale still counts, as its own visitor
import { fromStripe } from 'nahnu-analytics-sdk';
const sale = fromStripe(event);
if (sale) await stats.events.send(sale.site ?? website.id, sale.event);Which runtimes are supported?
Node 18 or later, or any runtime with fetch and Web Crypto, such as Deno, Bun and edge runtimes.
Can a stats error break my checkout?
No. track() never throws. It returns false and passes the error to onError.
Will a webhook sent twice count twice?
No. The same event id within three days counts once.
Is the platform key safe in my app?
Keep it on your server only, never in a browser bundle or an app.
Try it on every client site.
Unlimited websites, every feature, one license.