Developers · Server-side events
Server-side tracking that ad blockers can’t touch.
Send sales, signups and leads from PHP, a webhook, a cron job or your app’s server. Each one joins the visitor’s visit, so the source that brought them gets the credit, and it’s counted once.
nahnu_analytics_track( 'Lead won', array(
'props' => array( 'plan' => 'pro' ),
'revenue' => array( 'amount' => 490, 'currency' => 'USD' ),
) );await stats.track(request, website.id, 'Purchase', {
revenue: { amount: 49, currency: 'USD' },
});Where your code runs
Four ways in, one event.
Pick the one that matches where your code runs. Every way sends the same event, and it lands in the same Goals and events card.
A client’s WordPress
nahnu_analytics_track() in PHP, with the free connector.
Events, filters and actions →Your own WordPress
nahnu_analytics_send_event() on the site with the plugin.
Where to plug in →Anywhere else
The REST API with a key, from a CRM, a payment webhook or a script.
The REST API →Your own product
track() and events.send() in the TypeScript SDK.
The SDK →
Why server-side
The numbers your client is paid on.
Sales and leads are the events that matter most, and the ones a browser loses most often. Send them from the server instead.
Not lost to ad blockers
The event goes from your server, not the visitor’s browser.
Joined to the visit
With the visitor’s address and browser, the sale gets the source that brought them.
Counted once
The same event id within 3 days counts once, so a webhook sent again isn’t a second sale.
Never breaks a checkout
The SDK’s track() never throws. A stats hiccup can’t stop an order.
From WordPress
One function on a client’s site.
With the free connector, nahnu_analytics_track() records an event for the current visitor. From a webhook or a cron job, pass the visitor’s ip and user_agent too.
- Shows in the website’s Goals and events card, with its revenue
- Break it down by any property, such as plan
- do_action() works without checking that the plugin is active
- Filters change or drop any event before it’s sent
// The same, without checking that the plugin is active:
do_action( 'nahnu_analytics_track', 'Lead won', array(
'props' => array( 'plan' => 'pro' ),
) );add_filter( 'nahnu_analytics_connector_event', function ( $event ) {
return $event; // or null to leave it out
} );Stripe and Shopify
Webhooks become sales.
Add the visit to the Stripe Checkout Session, then turn the webhook into a sale with one helper. For Shopify, fromShopify() uses the buyer’s address and browser that Shopify keeps.
- Paid checkouts become Purchase, renewals become Subscription renewed
- Amounts converted from Stripe’s cents, in every currency
- Shopify test orders are left out
- Event ids set for you, so a resent webhook counts once
import { stripeMetadata, fromStripe } from 'nahnu-analytics-sdk';
// Creating the Checkout Session, inside the buyer's request
await stripe.checkout.sessions.create({ /* … */ metadata: { ...stripeMetadata(request, website.id) } });
// Your Stripe webhook
const sale = fromStripe(event);
if (sale) await stats.events.send(sale.site ?? website.id, sale.event);The event
One small JSON object.
The same fields everywhere: in PHP, the SDK and the REST API. Send one, or up to 50 in a single call.
- name
- Required. The event, such as Lead won or Purchase.
- props
- Properties to break it down by, such as plan.
- revenue
- An amount and a currency.
- id
- Your order or webhook id. The same id within 3 days counts once.
- ip · user_agent
- The visitor’s address and browser, so the event joins their visit.
- url
- The page it happened on.
{"name": "Lead won", "props": {"plan": "pro"},
"revenue": {"amount": 490, "currency": "USD"},
"url": "https://example.com/thanks",
"ip": "203.0.113.9", "user_agent": "Mozilla/5.0 …",
"id": "order-1001"}Does a server-side event become a goal?
An event becomes a goal when you add a goal with its name, once. Funnels then work across these events and pages.
What if I don’t have the visitor’s address?
The event still counts, as its own visitor. With the address and browser, it joins the visit and the source gets the credit.
Will a resent webhook count twice?
No. Give every event an id, such as your order number. The same id within 3 days counts once.
Do sales from WooCommerce need code?
No. The free connector sends WooCommerce, SureCart, FluentCart and Easy Digital Downloads orders from the server by itself.
How many events can I send at once?
Up to 50 in one call, and the batch counts as one request against the rate limit.
Count every sale, even with ad blockers.
Unlimited websites, every feature, one license.