Codex LaboratoriesAnalytics
Sign inGet started

Developers

Everything needed to put a property on the pipeline - the beacon, the ingest contract, and the rules the server enforces.

Install the beacon

Register the property in the dashboard to get its trk_ tracking ID, then place this in your site's <head>:

<script>
  window.ANALYTICS_TRACKING_ID = 'trk_your_id';
  window.ANALYTICS_API_ENDPOINT = 'https://analytics.codexlabsai.com/api/events';
</script>
<script src="https://codexlabsai.com/analytics.js" defer></script>

The beacon is ~3 KB, loads with defer, uses sendBeaconwith a fetch fallback, and needs no API key - the endpoint is a public beacon by design, with CORS restricted to an explicit origin allowlist.

Ingest contract

POST /api/events accepts a single event or a batch ({"events":[...]}, max 100). Schema version v:1:

{
  "v": 1,
  "trackingId": "trk_your_id",        // required
  "type": "pageview | custom | conversion | error",
  "url": "https://...",               // pageview events
  "referrer": "https://...",          // optional
  "userAgent": "...",                 // optional; server reads the header too
  "sessionId": "ses_...",             // optional; server mints if absent
  "visitorId": "vst_...",             // optional
  "eventId": "evt_...",               // dedup key - safe to retry
  "timestamp": "ISO-8601",            // optional; server time wins for freshness
  "name": "button_click",             // required for custom/conversion
  "properties": { "key": "value" }    // optional, JSON object
}

Browser API

Once the beacon loads, window.Analytics exposes:

window.Analytics.trackPageview()                    // manual pageview
window.Analytics.trackEvent(name, properties?)      // custom event
window.Analytics.trackConversion(name, value?, currency?, properties?)

CSP note: if your pages set a Content-Security-Policy, allow script-src https://codexlabsai.com and connect-src https://analytics.codexlabsai.com.