Developer Documentation
Build on VeritaMetrics
Everything you need to integrate privacy-first analytics into your application. Track custom events, consume webhooks, query the REST API, and deploy self-hosted.
Tracking API
The client-side tracking API is available on any page that includes the VeritaMetrics snippet. Pageviews are tracked automatically. Use the API to track custom events, revenue, and goals.
Custom Events
Track any user action with a name and optional metadata. Events appear in your dashboard within seconds.
Revenue Tracking
Attach order IDs, amounts, and currency to attribute revenue to traffic sources and campaigns.
No-Code Goals
Add data-verita-event-name="Signup" to any HTML element. Clicks are tracked automatically, no JavaScript required. Attach properties
with data-verita-prop-* attributes.
How events appear in your dashboard
Top Events groups your events by name, so form_submit and Signup each appear as
their own row with its own total. Open a row to drill in: the panel breaks that event down
by the page it fired on, an element label, and the link destination. Any other properties
you send are stored and appear in your CSV, JSON, and XLSX exports; they are not charted as
a separate breakdown. To split one event by a value (which plan, which card, which button),
put that value in the event name, or send it as a text property so it shows under the label breakdown.
Core Web Vitals (optional)
Collect real-user LCP, INP, and CLS by adding data-web-vitals="true" to your tracking script tag (see the code panel). It is off by default and available on
every plan, including Free. The tracker reports each metric once per page on hide, and the
dashboard shows the p75. See the Web Vitals page for how field data differs from a lab test.
Warm-lead intent signal (optional)
Add data-warm-lead="true" to
your script tag and the tracker scores the session cookielessly, then dispatches a
veritametrics:intent DOM event
(and runs any window.verita("onIntent", cb) callbacks) once the session turns warm or hot on exit intent. The detail is
{ tier, score, reasons }, with no personal data. Use it to open a form or ping your CRM. See the warm-lead capture guide.
Visitor opt-out
window.verita("optOut") stops
collection at once and records the choice in one
localStorage key, so later
visits to your site load the tracker and it exits before attaching a single listener.
window.verita("optIn") clears
it. Wire both to a control on your privacy page. The commands are safe to call on a page where
the tracker has already opted out, and they do not throw when a browser blocks storage, though
in that case the choice lasts only for the current page load. This is separate from Global
Privacy Control and Do Not Track, which the tracker honours on its own with no code from you.
// Track a custom event
window.verita("trackEvent", "form_submit", {
formId: "contact",
source: "homepage"
}); // Track a purchase with revenue
window.verita("trackRevenue", {
orderId: "ORD-1234",
amount: 49.99,
currency: "USD"
}); // Stop collecting for this visitor, on this
// site, and remember it across visits
window.verita("optOut");
// Undo it
window.verita("optIn"); <!-- No JavaScript needed -->
<button
data-verita-event-name="Signup"
data-verita-prop-plan="pro"
>
Create Account
</button> // Pass "text" to break the event down by that value
window.verita("trackEvent", "cta_click", {
text: "Create a free account"
});
// Or encode the value in the event name itself
window.verita("trackEvent", "signup_pro"); <!-- Add data-web-vitals to enable LCP, INP, CLS -->
<script
defer
data-site-id="YOUR_SITE_ID"
data-web-vitals="true"
src="https://www.veritametrics.com/tracker.js"
></script> // Enable with data-warm-lead="true" on the tag,
// then listen for the browser event:
document.addEventListener("veritametrics:intent", (e) => {
// e.detail = { tier, score, reasons } (no PII)
if (e.detail.tier === "hot") openYourForm();
});
// or a callback:
window.verita("onIntent", (detail) => {
// detail = { tier, score, reasons }
}); import crypto from "crypto";
function verifySignature(
payload: string,
signature: string,
secret: string
): boolean {
const expected = crypto
.createHmac("sha256", secret)
.update(payload)
.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
// In your handler:
const sig = req.headers["x-verita-signature"];
const isValid = verifySignature(
req.body, sig, WEBHOOK_SECRET
); Retry Policy
Failed deliveries are retried up to 3 times with exponential backoff (1s, 4s, 16s). Every attempt is logged with full request/response details in the delivery log.
Webhook API
Receive real-time events from VeritaMetrics via HTTP POST. Every payload is signed with HMAC-SHA256 using your endpoint's secret so you can verify authenticity.
Signature Verification
Each request includes an X-Verita-Signature header. Compute the HMAC-SHA256 hex digest of the raw request body using your secret and
compare.
Event Types
-
alert.triggered: anomaly or threshold alert fired -
goal.completed: a tracked goal was achieved -
report.ready: a scheduled export is available -
test: manual test delivery from settings
REST API
Query your analytics data programmatically. All endpoints return JSON and require authentication via API key.
| Method | Endpoint |
|---|---|
| GET | /api/sites/:id/stats |
| GET | /api/sites/:id/events |
| GET | /api/sites/:id/funnels |
| POST | /api/sites/:id/webhooks |
| GET | /api/sites/:id/alert-rules |
| POST | /api/sites/:id/export |
See the full API reference, with parameters and example responses
Framework Guides
Deep integration guides for popular frameworks. Each guide covers installation, route tracking, custom events, and platform-specific features.
Next.js
App Router client component with automatic route change tracking.
- App Router compatible
- Automatic SPA navigation
- Server-side pixel fallback
Astro
Native component with View Transitions support across MPA and SPA modes.
- View Transitions support
- Island architecture
- Zero client JS option
React
React component with React Router integration and custom event hooks.
- React Router integration
- Automatic route tracking
- Custom event hooks
WordPress
Add via functions.php or a code-snippets plugin. WooCommerce revenue support.
- Server-side pixel
- WooCommerce revenue
- No plugin dependency
Shopify
Liquid snippet in theme.liquid. Tracks product views, carts, and purchases.
- Revenue tracking
- Checkout funnel
- Product page analytics
Flutter
Dart NavigatorObserver for Flutter web apps with automatic route tracking.
- Navigator observer
- Automatic routes
- Web platform support
The same snippet also drops into these platforms and CMSs:
Self-Hosting
For teams that need maximum control over their data. Deploy VeritaMetrics on your own infrastructure with our self-hosting package.
Full Data Sovereignty
All analytics data stays on your servers. Nothing leaves your network.
Docker Deployment
Ship as a Docker container with PostgreSQL. One command to deploy.
Same Feature Set
Every feature available in the cloud version, running on your infrastructure.
Premium Support
Available for premium plan customers needing specific compliance or security setups.
Data Model
Understanding how VeritaMetrics processes and stores your analytics data, and what gets pseudonymized.
Visits
Each pageview or event hit creates a visit record. Visits are attributed to a pseudonymous daily visitor hash, unique within a 24-hour window, not across days.
Events
Custom events carry a name and optional properties (key-value metadata). Revenue events additionally store amount, currency, and order ID.
Funnels
Define multi-step conversion funnels from pageviews or events. The engine computes step-by-step conversion rates, drop-off points, and overall completion.
Pseudonymization
IP addresses are used momentarily for geo-lookup and generating a daily salted hash, then immediately discarded. No raw IPs are ever stored.
Retention
Configure per-site retention periods. Raw visit data is automatically purged after expiry; aggregated reports are preserved for long-term trend analysis.
Aggregation
Daily and hourly aggregates power the dashboard. These include visitor counts, pageview totals, bounce rates, engagement metrics, and geographic breakdowns.
Start Building With VeritaMetrics
Sign up for free and get your site ID and tracking snippet in under a minute.