How do I send revenue from my own checkout or any payment provider to my analytics?
Call DataFast's revenue API from your server after a payment succeeds: POST /api/revenue with a revenue API key as a Bearer token, plus site_id, amount, currency, the visitor_id captured at checkout and your order ID as event_id. Retries with the same event_id are not counted twice, and the payment appears under its original source.
Steps
- Create a revenue API key. In the site's settings. It is shown once; keep it server-side.
- Capture the visitor ID. window.datafast?.visitorId in the browser, sent to your server with the checkout request.
- Call the API after payment. curl -X POST https://datafast.app/api/revenue -H "Authorization: Bearer KEY" -H "Content-Type: application/json" -d '{"site_id":"SITE_ID","amount":49.00,"currency":"USD","visitor_id":"VISITOR_ID","event_id":"ORDER_ID"}'
Limits
- The key is a write key: never ship it to the browser.
- amount must be greater than 0.
FAQ
What stops duplicates?
Send your order ID as event_id (or the Idempotency-Key header); the same ID is recorded once.
Can the MCP token call this?
No. The MCP token is read-only and refused here.
Related
- How do I see Stripe revenue by traffic source?
- How do I attribute LemonSqueezy or Paddle sales to a traffic source?
- Revenue analytics
Markdown version: /solutions/add-revenue-tracking-to-any-checkout.md