Metrone Documentation
Privacy-first analytics for humans and AI agents. Track website visitors, voice calls, chat sessions, and AI interactions — all from your own domain.
Quickstart
5 minGo from zero to live analytics in three steps.
Create a project
Sign up at app.metrone.io, create a project, and copy your API key from Settings > API Keys.
Add the tracking script
Drop one line into your site's <head>:
<script defer src="https://cdn.metrone.io/m.js" data-key="metrone_live_YOUR_KEY"></script>
For production, use a CNAME setup so tracking runs entirely from your own domain and bypasses ad blockers.
Track AI interactions (optional)
If you use voice agents or chatbots, paste a webhook URL into your platform's settings:
https://api.metrone.io/v1/webhooks/vapi/main?key=metrone_live_YOUR_KEY
Or use the Server SDK / REST API for full control. Data flows into the same dashboard — web events and AI events side by side.
Why first-party only
Your analytics is about your visitors on your site. It belongs on your domain. When analytics runs as a third-party script from a vendor URL, it introduces unnecessary external requests, raises privacy concerns, and creates a dependency you don't control. Every Metrone integration method — CNAME, NPM, or Edge proxy — serves tracking from your own domain. No third-party requests leave the browser.
For Humans
Browser tracking, React integration, and custom events.
CNAME setup
RecommendedOne DNS record. One script tag. Works with any website.
Add a DNS record
Go to your domain's DNS settings and add a CNAME record:
This creates a first-party endpoint on your domain (e.g. data.yoursite.com). All requests stay on your domain.
Add the script tag
Add this to your <head>:
<script defer src="https://data.yoursite.com/m.js" data-key="metrone_live_YOUR_API_KEY" data-api="https://data.yoursite.com/v1/events"> </script>
Page views are tracked automatically. Data appears in your dashboard within seconds.
Browser SDK
For React, Vue, Next.js, Nuxt, SvelteKit, or any JavaScript app with a build step.
Install
npm install @metrone-io/sdk
Initialize
import { Metrone } from '@metrone-io/sdk'
const metrone = new Metrone('metrone_live_YOUR_API_KEY')
// Page views are tracked automatically
metrone.track('signup', { plan: 'growth', source: 'landing' })SPA route tracking
const metrone = new Metrone({
apiKey: 'metrone_live_YOUR_API_KEY',
autoTrackSPA: true,
})Full config
import { Metrone } from '@metrone-io/sdk'
import type { AnalyticsConfig } from '@metrone-io/sdk'
const config: AnalyticsConfig = {
apiKey: 'metrone_live_YOUR_API_KEY',
autoTrackSPA: true,
batchSize: 10, // events per batch
flushInterval: 5000, // ms between flushes
debug: false,
respectDoNotTrack: false,
anonymizeIP: true,
}
const metrone = new Metrone(config)Zero-dependency, tree-shakeable. ~2 KB gzipped.
React SDK
Provider, hooks, and HOC for React 18+ apps.
Install
npm install @metrone-io/react @metrone-io/sdk
Add the provider
import { MetroneProvider } from '@metrone-io/react'
function App() {
return (
<MetroneProvider
config={{ apiKey: 'metrone_live_YOUR_API_KEY', autoTrackSPA: true }}
trackRouteChanges
>
<YourApp />
</MetroneProvider>
)
}Use the hook
import { useMetrone } from '@metrone-io/react'
function CheckoutButton() {
const { trackEvent, trackConversion } = useMetrone()
return (
<button onClick={() => {
trackConversion('purchase', 69, { plan: 'growth' })
}}>
Buy now
</button>
)
}Available hooks: useMetrone() and useAnalytics(options). HOC: withMetrone(Component).
Edge function proxy
AdvancedCloudflare Workers, Vercel Edge, or Netlify Edge.
export default {
async fetch(request) {
const url = new URL(request.url)
if (url.pathname === '/m.js')
return fetch('https://api.metrone.io/m.js')
if (url.pathname.startsWith('/v1/'))
return fetch('https://api.metrone.io' + url.pathname, {
method: request.method,
headers: request.headers,
body: request.body,
})
return fetch(request)
},
}<script defer src="https://yoursite.com/m.js" data-key="metrone_live_YOUR_API_KEY" data-api="https://yoursite.com/v1/events"> </script>
Custom events
Track signups, purchases, clicks, form submissions — anything.
metrone.track('purchase', {
plan: 'growth',
value: 69,
currency: 'USD',
})
metrone.conversion('signup', 1, { source: 'landing' })
metrone.interaction('click', 'cta_hero')curl -X POST https://api.metrone.io/v1/events \
-H "Content-Type: application/json" \
-d '{
"api_key": "metrone_live_YOUR_API_KEY",
"event_type": "custom",
"event_name": "purchase",
"source": "web",
"page_url": "https://yoursite.com/checkout",
"properties": { "plan": "growth", "value": 69 }
}'For AI Agents
Server SDK, MCP protocol, webhooks, real-time streaming, and the full REST API.
Server SDK
NewFor Node.js, Deno, Bun, or any server-side JavaScript runtime.
Install
npm install @metrone-io/server
Initialize and track
import { MetroneServer } from '@metrone-io/server'
const metrone = new MetroneServer({
apiKey: 'metrone_live_YOUR_API_KEY',
})
// Track events
metrone.pageview('https://yoursite.com/pricing', 'Pricing')
metrone.track('api_request', { endpoint: '/users', method: 'GET' })
// Track AI interactions
metrone.trackAICall({
callId: 'call_abc123',
provider: 'vapi',
duration: 47,
intent: 'book_appointment',
outcome: 'completed',
})
// Graceful shutdown (flushes pending events)
await metrone.shutdown()Read analytics
// Read aggregated stats
const stats = await metrone.getStats({ days: 30 })
console.log(stats.pageviews, stats.unique_visitors)
// Read events with pagination
const events = await metrone.getEvents({ limit: 50, event_type: 'conversion' })
// Get live visitor count
const live = await metrone.getLive()
console.log(live.active_visitors)Error handling
import { MetroneServer, MetroneAuthError, MetroneRateLimitError } from '@metrone-io/server'
try {
await metrone.flush()
} catch (err) {
if (err instanceof MetroneAuthError) { /* invalid API key */ }
if (err instanceof MetroneRateLimitError) { /* back off */ }
}Auto-batching, retry with exponential backoff, offline queue. Events are flushed every 5 seconds or when the batch reaches 10 events.
MCP Server
NewModel Context Protocol — let AI assistants query and track analytics.
Install
npm install -g @metrone-io/mcp
Configure Claude Desktop
{
"mcpServers": {
"metrone": {
"command": "npx",
"args": ["@metrone-io/mcp"],
"env": {
"METRONE_API_KEY": "metrone_live_YOUR_API_KEY"
}
}
}
}Available tools:
metrone_get_statsAggregated stats (pageviews, visitors, bounce rate, conversions)metrone_get_eventsQuery events with filtering by type and sourcemetrone_get_pagesTop pages with visitor countsmetrone_get_sourcesTraffic source breakdownmetrone_get_liveReal-time active visitor countmetrone_track_eventTrack a custom eventmetrone_track_ai_callTrack an AI voice/chat interactionWorks with any MCP-compatible client: Claude Desktop, Cursor, or custom agents.
Webhooks
Paste a URL into your AI platform. Zero code required.
Get your webhook URL from Dashboard > Settings > Integrations, or construct it:
https://api.metrone.io/v1/webhooks/{platform}/{endpointId}?key=metrone_live_YOUR_API_KEY
# Examples
https://api.metrone.io/v1/webhooks/twilio/main?key=metrone_live_...
https://api.metrone.io/v1/webhooks/vapi/support-agent?key=metrone_live_...
https://api.metrone.io/v1/webhooks/retell/sales?key=metrone_live_...
https://api.metrone.io/v1/webhooks/telnyx?key=metrone_live_...
https://api.metrone.io/v1/webhooks/intercom?key=metrone_live_...
https://api.metrone.io/v1/webhooks/zendesk?key=metrone_live_...Labeled endpoints let you organize by location or purpose:
# One restaurant, multiple locations .../v1/webhooks/twilio/falls-church?key=... .../v1/webhooks/twilio/rockville?key=... .../v1/webhooks/twilio/main-line?key=...
Paste the URL into your platform's webhook settings. Voice calls, chat sessions, and assistant queries appear in your dashboard automatically. Metrone classifies call intents (scheduling, pricing, support, etc.) from the call data.
Webhook verification
Verify that incoming webhooks are authentic.
Metrone verifies webhook signatures for platforms that support it. Add your platform's signing secret in Settings > Integrations.
HMAC-SHA256X-Twilio-SignatureAuth token from Twilio consoleEd25519telnyx-signature-ed25519Public key from Telnyx portalHMAC-SHA1X-Hub-SignatureClient secret from Intercom appHMAC-SHA256X-Zendesk-Webhook-SignatureSigning secret from Zendesk webhooksVAPI, Retell, Bland, OpenAI, and Anthropic don't sign webhooks — Metrone validates their payloads structurally. Signature verification is optional; if no secret is configured, webhooks are accepted without verification.
REST API
Full read/write access to your analytics data from any language.
Write events:
curl -X POST https://api.metrone.io/v1/events \
-H "Content-Type: application/json" \
-d '{
"api_key": "metrone_live_YOUR_API_KEY",
"event_type": "ai_call",
"source": "voice",
"ai_provider": "vapi",
"ai_call_id": "call_abc123",
"ai_intent": "book_appointment",
"ai_duration_sec": 47
}'curl -X POST https://api.metrone.io/v1/events/batch \
-H "Content-Type: application/json" \
-d '[
{ "api_key": "metrone_live_...", "event_type": "pageview", "page_url": "https://..." },
{ "api_key": "metrone_live_...", "event_type": "conversion", "properties": { "value": 99 } }
]'Read analytics:
curl https://api.metrone.io/v1/api/stats?days=30 \ -H "X-Api-Key: metrone_live_YOUR_API_KEY"
curl -X POST https://api.metrone.io/v1/api/query \
-H "X-Api-Key: metrone_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"queries": [
{ "type": "stats", "params": { "days": 7 } },
{ "type": "pages", "params": { "limit": 10 } },
{ "type": "live" }
]
}'Real-time SSE
Server-Sent Events stream for live dashboards and monitoring.
curl -N https://api.metrone.io/v1/api/stream \
-H "X-Api-Key: metrone_live_YOUR_API_KEY"
# Events arrive as they happen:
# data: {"event_type":"pageview","page_path":"/pricing","timestamp":"..."}
# data: {"event_type":"conversion","source":"voice","ai_provider":"twilio",...}const es = new EventSource(
'https://api.metrone.io/v1/api/stream?api_key=metrone_live_YOUR_API_KEY'
)
es.onmessage = (e) => {
const event = JSON.parse(e.data)
console.log(event.event_type, event.page_path)
}Streams last up to 5 minutes. Max 5 concurrent connections per API key.
Features
Deep-dive into Metrone's core capabilities.
Funnels & AI attribution
Growth+Multi-step conversion funnels with source attribution and AI-assisted conversion tracking.
Funnels let you define a sequence of conversion goals and measure how users progress through them — with a twist no other analytics tool offers: AI attribution.
Conversion Goals
A goal matches events by one or more criteria:
Source Attribution
Each funnel step shows which channel drove completions. Sources are classified into five categories:
AI-Assisted Conversions
A conversion is AI-assisted when the session that completed the final funnel step also contained at least one AI interaction (voice call, chat session, or assistant query). This metric answers: "How many conversions involved AI?"
A user visits your landing page (Web), then calls your VAPI voice agent to ask about pricing (Voice AI), then returns and completes checkout (Web). The funnel shows each step's source breakdown, and the final conversion is flagged as AI-assisted because the session included a voice call.
Available on the Growth plan and above. Navigate to Dashboard > Goals & Funnels to create goals and build funnels.
AI Assistant
All plansAsk questions about your data in natural language.
Every Metrone project includes a built-in AI assistant powered by Claude Sonnet 4.6 (with Llama 3.3 70B fallback). Open it from the sidebar in any dashboard.
What it knows
The assistant receives your project's last 30 days of analytics data as structured context. It can answer questions about:
Web analytics
Pageviews, visitors, top pages, referrers, UTM campaigns, geo breakdown
Voice AI calls
Total/completed/failed calls, duration, resolution rate, cost, by provider, top intents
Chat AI sessions
Total sessions, messages, avg messages, by provider and model
Conversion funnels
Goal completions, funnel drop-off, source attribution, AI-assisted rate
Traffic sources
Direct, organic, social, referral, campaign — with session counts
Product knowledge
Any question about Metrone features, pricing, SDKs, integrations, philosophy
Example questions
"What was my top traffic source this month?"
"How many voice calls were resolved vs failed?"
"Which funnel has the highest drop-off rate?"
"What percentage of conversions involved AI interactions?"
"Compare my desktop vs mobile traffic."
"Which AI provider has the best resolution rate?"
Rate limit: 60 messages per hour per project. Context window: last 20 messages in the current conversation.
Reference
API endpoints
All available endpoints on api.metrone.io (or your CNAME domain).
Ingestion — write events
/v1/eventsIngest a single event/v1/events/batchIngest up to 100 events/v1/webhooks/:platform/:endpointIdWebhook ingestionRead API — query analytics (requires API key)
/v1/api/statsAggregated stats (pageviews, visitors, bounce, conversions)/v1/api/eventsEvents with cursor pagination/v1/api/pagesTop pages by pageviews/v1/api/sourcesTraffic sources and referrers/v1/api/liveLive active visitor count/v1/api/streamReal-time SSE event stream/v1/api/queryBatch query (multiple reads in one request)System
/m.jsLightweight tracking script (~2 KB)/v1/healthLiveness checkAuthentication
Three ways to authenticate API requests.
X-Api-Key: metrone_live_...RecommendedAuthorization: Bearer metrone_live_...Standard OAuth style?api_key=metrone_live_...SSE and browser useIdempotency: Include an Idempotency-Key header on POST requests to prevent duplicate events. The key is cached for 24 hours.
Request tracing: Every response includes an X-Request-Id header. Include your own in the request to correlate with your logs.
Error codes
Structured JSON errors with machine-readable codes.
{
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests. Try again in 60 seconds.",
"status": 429,
"request_id": "req_abc123_xyz789"
}
}INVALID_PAYLOADMissing or malformed fieldsINVALID_JSONRequest body is not valid JSONBATCH_EMPTYBatch array is emptyBATCH_TOO_LARGEBatch exceeds 100 eventsBATCH_MIXED_KEYSBatch contains different API keysMISSING_API_KEYNo API key providedINVALID_API_KEYAPI key not found or inactiveFORBIDDENAPI key lacks required scopeNOT_FOUNDEndpoint does not existDUPLICATE_EVENTIdempotency key already usedBODY_TOO_LARGERequest body exceeds 512 KBRATE_LIMITEDToo many requestsQUOTA_EXCEEDEDMonthly event quota reachedWRITE_FAILEDDatabase write errorINTERNAL_ERRORUnexpected server errorSDK configuration
All config options for browser and server SDKs.
Browser SDK — @metrone-io/sdk
apiKeystringrequiredYour Metrone API keyautoTrackSPAbooleanfalseTrack route changes automaticallybatchSizenumber10Events per batchflushIntervalnumber5000Ms between flushesdebugbooleanfalseLog to consolerespectDoNotTrackbooleanfalseHonor browser DNT settinganonymizeIPbooleantrueHash visitor IPs server-sideofflineQueuebooleantrueQueue events when offlinemaxQueueSizenumber100Max offline queue sizeServer SDK — @metrone-io/server
apiKeystringrequiredYour Metrone API keyendpointstringhttps://api.metrone.ioAPI base URLbatchSizenumber10Events per batchflushIntervalMsnumber5000Ms between flushesmaxRetriesnumber3Retry attempts on failuretimeoutMsnumber10000Request timeoutdebugbooleanfalseLog to consoleSupported platforms
Webhook integrations for voice, chat, and AI assistant platforms.
Twilio
Voice & SMS
/v1/webhooks/twilio/{<id>}Telnyx
Voice & SMS
/v1/webhooks/telnyx/{<id>}VAPI
Voice AI agents
/v1/webhooks/vapi/{<id>}Retell
Voice AI agents
/v1/webhooks/retell/{<id>}Bland
Voice AI agents
/v1/webhooks/bland/{<id>}OpenAI
Chat & assistants
/v1/webhooks/openai/{<id>}Anthropic
Chat & assistants
/v1/webhooks/anthropic/{<id>}Intercom
Conversations & tickets
/v1/webhooks/intercom/{<id>}Zendesk
Tickets & chat
/v1/webhooks/zendesk/{<id>}Any platform with outgoing webhooks works with Metrone. Contact us if you need help with a specific integration.