Track Endpoint

Send pageview and event data to Zero Trust Analytics

Overview

The Track endpoint receives pageview and event data from your website. This is what the tracking script uses internally, but you can also call it directly for server-side tracking.

Endpoint

POST /api/track

Note: This endpoint doesn’t require authentication - it uses your Site ID for authorization.

Request Headers

Content-Type: application/json

Request Body

Pageview

{
  "type": "pageview",
  "siteId": "site_abc123",
  "path": "/blog/my-article",
  "referrer": "https://google.com",
  "utm": {
    "source": "google",
    "medium": "cpc",
    "campaign": "summer-sale"
  }
}

Custom Event

{
  "type": "event",
  "siteId": "site_abc123",
  "path": "/pricing",
  "action": "signup_click",
  "category": "conversion",
  "label": "hero_button",
  "value": 1
}

Engagement (Session End)

{
  "type": "engagement",
  "siteId": "site_abc123",
  "path": "/blog/my-article",
  "sessionId": "sess_xyz789",
  "timeOnPage": 45,
  "isBounce": false
}

Parameters

ParameterTypeRequiredDescription
typestringYesEvent type: pageview, event, engagement, heartbeat
siteIdstringYesYour unique Site ID
pathstringNoPage path (defaults to /)
referrerstringNoReferring URL
utmobjectNoUTM campaign parameters
utm.sourcestringNoCampaign source
utm.mediumstringNoCampaign medium
utm.campaignstringNoCampaign name
actionstringNoEvent name (for custom events)
categorystringNoEvent category
labelstringNoEvent label
valuenumberNoEvent value
sessionIdstringNoSession identifier
timeOnPagenumberNoTime spent on page in seconds
isBouncebooleanNoWhether this was a bounce

Response

Success

{
  "success": true
}

Error

{
  "error": "Invalid site ID"
}

CORS

The Track endpoint supports CORS for browser-based requests. The Origin header must match your registered site domain.

Server-Side Tracking

For server-side tracking (Node.js, Python, etc.), call the endpoint directly:

// Node.js example
const response = await fetch('https://ztas.io/api/track', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    type: 'pageview',
    siteId: 'site_abc123',
    path: '/api-tracked-page'
  })
})

Bot Filtering

The endpoint automatically filters common bots and crawlers. Bot traffic is silently ignored (returns success: true but doesn’t store data).