Privacy-respecting, self-hosted analytics tracker using Context VM and Nostr.
This is a lightweight browser tracker that sends page view events to your own Context VM backend via Nostr relays. All data is end-to-end encrypted using NIP-44.
Key features:
- Self-hosted - you control your analytics data
- Privacy-respecting - no cookies, no personal data
- End-to-end encrypted via NIP-44
- ~79KB browser bundle
Before using this tracker, you need:
- A Context VM backend running the nanalytics server
- Your CVM's public key (64 character hex string)
- A Site UUID - generate one for each website you want to track
Add this before </body> on every page you want to track:
<script
src="https://unpkg.com/nanalytics-tracker/dist/index.global.js"
data-site-uuid="YOUR_SITE_UUID"
data-cvm-pubkey="YOUR_CVM_PUBKEY"
></script>If you're running your own Nostr relays:
<script
src="https://unpkg.com/nanalytics-tracker/dist/index.global.js"
data-site-uuid="YOUR_SITE_UUID"
data-cvm-pubkey="YOUR_CVM_PUBKEY"
data-relays="wss://your-relay.com,wss://backup-relay.com"
></script>npm install nanalytics-trackerimport { init, trackPageView } from 'nanalytics-tracker';
init({
siteUuid: 'YOUR_SITE_UUID',
cvmPubkey: 'YOUR_CVM_PUBKEY',
relays: ['wss://your-relay.com'], // optional
onTrack: (success) => console.log('Tracked:', success) // optional
});
// For SPAs, manually track route changes:
trackPageView('/new-route');| Option | Required | Description |
|---|---|---|
data-site-uuid / siteUuid |
Yes | Unique identifier for your website (UUID format) |
data-cvm-pubkey / cvmPubkey |
Yes | Your Context VM server's public key (64 hex chars) |
data-relays / relays |
No | Comma-separated relay URLs (defaults to wss://relay.contextvm.org, wss://cvm.otherstuff.ai) |
onTrack |
No | Callback fired after each track attempt (JS API only) |
Each page view sends:
| Field | Description |
|---|---|
siteUuid |
Your site identifier |
pagePath |
Current page pathname (e.g., /, /about) |
deviceType |
desktop, mobile, or tablet |
Not tracked: IP addresses, cookies, personal data, referrer (planned for future)
- On page load, the tracker collects the page path and device type
- Generates an ephemeral keypair (discarded after use)
- Creates a JSON-RPC
record_visittool call - Encrypts the message using NIP-44 (gift wrap)
- Publishes to configured Nostr relays
- Your CVM backend receives and decrypts the event
- Auto-tracks on page load - no code required for static sites
- Debounces duplicates - ignores rapid refreshes (5s window)
- Fire-and-forget - doesn't block page rendering
- End-to-end encrypted - only your CVM can read the data
- No cookies - compliant with privacy regulations
See docs/install_on_your_site.md for detailed setup instructions.
MIT