Skip to content
Skip to main content

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, the link destination, and every property the event carries. To split one event by a value (which plan, which card, which button), send that value as a property. It gets its own section listing the ten most common values, as soon as events start arriving, with no definition to register first.

Two limits are worth knowing, and the panel states both on screen. A property with more than 50 distinct values is read as an identifier rather than a dimension and is left out, so an order id or a search term will not get a section. Counts cover the most recent 20,000 events of that type. Every property you send is stored either way, and appears in your CSV, JSON, and XLSX exports.

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.

Custom Event
// Track a custom event
window.verita("trackEvent", "form_submit", {
  formId: "contact",
  source: "homepage"
});
Revenue Event
// Track a purchase with revenue
window.verita("trackRevenue", {
  orderId: "ORD-1234",
  amount: 49.99,
  currency: "USD"
});
Visitor Opt-Out
// Stop collecting for this visitor, on this
// site, and remember it across visits
window.verita("optOut");

// Undo it
window.verita("optIn");
No-Code Goal (HTML)
<!-- No JavaScript needed -->
<button
  data-verita-event-name="Signup"
  data-verita-prop-plan="pro"
>
  Create Account
</button>
Event That Splits in the Dashboard
// 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");
Web Vitals (opt-in)
<!-- 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/api/tracker.js?siteId=YOUR-SITE-ID"></script>
<noscript>
  <img
    src="https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID"
    referrerpolicy="unsafe-url"
    alt=""
    width="1"
    height="1"
    style="display: none"
    aria-hidden="true"
  />
</noscript>
Warm-lead intent signal
// 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 }
});
Verify Webhook Signature (Node.js)
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

React

React component with React Router integration.

  • React Router integration
  • Automatic route tracking

WordPress

Our plugin takes a site id and no code, or install from functions.php.

  • Server-side pixel
  • Installs from functions.php

Shopify

Liquid snippet in theme.liquid. Tracks pageviews, and revenue you send.

  • Revenue tracking

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:

HTML GTM WordPress Shopify Next.js Astro React PHP +3 more

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.