Skip to main content

Documentation Index

Fetch the complete documentation index at: https://revlytics.co/docs/llms.txt

Use this file to discover all available pages before exploring further.

Endpoint

POST https://revlytics.co/api/event

Request

Send a JSON body with the event data:
curl -X POST https://revlytics.co/api/event \
  -H "Content-Type: application/json" \
  -d '{
    "type": "pageview",
    "site_id": "YOUR_SITE_ID",
    "session_id": "unique-session-id",
    "url": "https://example.com/pricing",
    "path": "/pricing",
    "hostname": "example.com",
    "title": "Pricing - Example",
    "referrer": "https://google.com",
    "timestamp": "2025-01-15T10:30:00Z",
    "screen": {
      "width": 1920,
      "height": 1080,
      "viewport_width": 1440,
      "viewport_height": 900,
      "pixel_ratio": 2
    },
    "language": "en-US",
    "user_agent": "Mozilla/5.0..."
  }'

Event types

TypeDescription
pageviewPage load or SPA navigation
pageleaveUser leaves a page (includes duration)
custom_eventCustom event (includes event_name and properties)
web_vitalsPerformance metrics (includes vitals object)
external_linkClick on an external link
errorJavaScript error
paymentPayment completion
identifyUser identification
button_clickButton click
form_submitForm submission
copyText copied to clipboard

Required fields

FieldTypeDescription
typestringEvent type (see above)
site_idstringYour site identifier
session_idstringUnique session identifier

Optional fields

FieldTypeDescription
visitor_idstringPersistent visitor identifier
user_idstringYour app’s user identifier
timestampstringISO 8601 timestamp
urlstringFull page URL
pathstringURL path
hostnamestringDomain name
titlestringPage title
referrerstringReferring URL
languagestringBrowser language
user_agentstringBrowser user agent
screenobjectScreen dimensions
utmobjectUTM parameters (source, medium, campaign, term, content)
ad_click_idsobjectAd click IDs (gclid, fbclid, msclkid, etc.)
durationnumberTime on page in ms (for pageleave)
event_namestringCustom event name (for custom_event)
propertiesobjectCustom event properties
vitalsobjectWeb Vitals (lcp, fid, cls, fcp, ttfb)
error_namestringError type name
error_messagestringError message
error_stackstringStack trace (max 2KB)
providerstringPayment provider name

Response

Success

{ "status": "ok" }
Status code: 202 Accepted

Error

{ "error": "Missing required fields: site_id, type, session_id" }
Status code: 400 Bad Request or 500 Internal Server Error

Server-side tracking

You can send events from your backend (e.g., for server-side rendered pages or API events):
await fetch("https://revlytics.co/api/event", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    type: "custom_event",
    site_id: "YOUR_SITE_ID",
    session_id: "server-" + Date.now(),
    event_name: "api_signup",
    properties: { source: "api" },
    timestamp: new Date().toISOString(),
  }),
});