> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# Collect an analytics event

**Published**: 2026-11-30
**Category**: Analytics & Tracking

## `POST /analytics/events`

**Collect an analytics event**

Records one analytics event. Always returns 204 with an empty body,
also when the event is dropped: an invalid body, an excluded IP or
path, tracking turned off, or a localhost origin.

Send `application/json` with `session_id` (a UUID per visit),
`visitor_id` (stable per browser, 8 to 64 characters), `event_type`,
`page_path` and `event_time` (ISO 8601). Every other field is
optional.

### Request Body

Content-Type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `session_id` | string | Yes | Required. Analytics session UUID. UUID format |
| `visitor_id` | string | Yes | Required. 8-64 characters |
| `cookie_visitor_id` | string \| null | No | Ignored. Accepted so older trackers keep working: the collector reads the cookie from the request |
| `visitor_id_source` | "cookie" \| "fingerprint" \| "hybrid" | No | One of: cookie, fingerprint, hybrid |
| `event_type` | "pageview" \| "scroll" \| "time_on_page" \| "cwv" \| "exit" \| "heartbeat" \| "click" \| "outbound_link" \| "file_download" \| "email_click" \| "phone_click" \| "rage_click" \| "dead_click" \| "copy" \| "form_start" \| "form_submit" \| "form_abandon" \| "form_field" \| "form_error" \| "heatmap_click" | Yes | Required. Kind of event, such as `pageview`, `heartbeat` or `click` |
| `page_url` | string | No | Max 2048 characters |
| `page_path` | string | Yes | Required. Max 1024 characters |
| `event_time` | string | Yes | Required. Event time (ISO 8601). A time far from the server clock is replaced by the receive time |
| `page_title` | string | No | Max 500 characters |
| `page_referrer` | string \| null | No | URL of the referring page |
| `scroll_depth` | number (0 to 100) \| null | No | Scroll depth as a percentage (0-100) |
| `time_on_page` | number (0 to 3600000) \| null | No | Time on page in milliseconds (max 3600000) |
| `engaged_time` | number (0 to 3600000) \| null | No | Active engagement time in milliseconds (max 3600000) |
| `lcp` | number (0 to 60000) \| null | No | Largest Contentful Paint in milliseconds (Core Web Vital) |
| `fid` | number (0 to 10000) \| null | No | First Input Delay in milliseconds (Core Web Vital) |
| `cls` | number (0 to 10) \| null | No | Cumulative Layout Shift score (unitless, Core Web Vital) |
| `ttfb` | number (0 to 30000) \| null | No | Time To First Byte in milliseconds |
| `inp` | number (0 to 10000) \| null | No | Interaction to Next Paint in milliseconds (Core Web Vital) |
| `utm_source` | string \| null | No | UTM source campaign parameter |
| `utm_medium` | string \| null | No | UTM medium campaign parameter |
| `utm_campaign` | string \| null | No | UTM campaign name parameter |
| `utm_term` | string \| null | No | UTM term campaign parameter |
| `utm_content` | string \| null | No | UTM content campaign parameter |
| `traffic_source` | "direct" \| "organic" \| "social" \| "paid" \| "referral" \| "email" \| "internal" \| "ai" \| null | No | Traffic source channel: direct, organic, social, paid, referral, email, internal, ai |
| `device_type` | "desktop" \| "laptop" \| "mobile" \| "tablet" \| null | No | Device category: desktop, laptop, mobile, tablet |
| `browser` | string \| null | No | Browser name |
| `browser_version` | string \| null | No | Browser version string |
| `os` | string \| null | No | Operating system name |
| `os_version` | string \| null | No | Operating system version string |
| `screen_width` | number (0 to 10000) \| null | No | Screen width in pixels |
| `screen_height` | number (0 to 10000) \| null | No | Screen height in pixels |
| `language` | string \| null | No | Browser language code |
| `content_locale` | string \| null | No | Language of the page being read. A language the site does not offer is stored as `null` |
| `timezone` | string \| null | No | Timezone name (IANA, e.g. Europe/Paris) |
| `referrer_domain` | string \| null | No | Domain of the referrer |
| `is_entry` | boolean | No | Send `true` on the first `pageview` of a visit: it opens the session, and later events only update an open one |
| `is_exit` | boolean | No | `true` on the event that ends the visit; the page report counts it as an exit from `page_path` |
| `max_scroll_depth` | number (0 to 100) \| null | No | Maximum scroll depth reached as a percentage (0-100) |
| `click_x` | number (0 to 32767) \| null | No | Horizontal click coordinate in pixels |
| `click_y` | number (0 to 32767) \| null | No | Vertical click coordinate in pixels |
| `click_element` | string \| null | No | Descriptor of the clicked element |
| `click_element_tag` | string \| null | No | Tag name of the clicked element |
| `click_element_id` | string \| null | No | ID attribute of the clicked element |
| `click_element_class` | string \| null | No | Class attribute of the clicked element |
| `click_element_text` | string \| null | No | Text content of the clicked element |
| `click_target_url` | string \| null | No | Target URL of the clicked link |
| `click_count` | number (min 1) \| null | No | Number of clicks recorded for the event |
| `viewport_width` | number (0 to 10000) \| null | No | Viewport width in pixels |
| `viewport_height` | number (0 to 10000) \| null | No | Viewport height in pixels |
| `file_name` | string \| null | No | Name of the downloaded file |
| `file_extension` | string \| null | No | Extension of the downloaded file |
| `file_url` | string \| null | No | URL of the downloaded file |
| `copied_text` | string \| null | No | Text copied by the visitor (copy event) |
| `scroll_behavior` | "reading" \| "skimming" \| "jumping" \| null | No | Scroll behavior pattern: reading, skimming, jumping |
| `form_id` | string \| null | No | Identifier of the form involved in the event |
| `form_name` | string \| null | No | Name of the form involved in the event |
| `field_name` | string \| null | No | Name of the form field involved in the event |
| `field_type` | string \| null | No | Type of the form field involved in the event |
| `field_time` | number (min 0) \| null | No | Time spent on the form field in milliseconds |
| `error_message` | string \| null | No | Form validation or submission error message |
| `form_completion_rate` | number (0 to 100) \| null | No | Form completion rate as a percentage (0-100) |


### Responses

| Status | Description |
| --- | --- |
| `204` | No content |
| `402` | The site subscription does not currently permit this operation |
| `422` | Validation error |


> **Notes:** Always 204 with an empty body. Rate-limit bucket: analytics, 600
> requests per minute per site and client.

### Examples

```curl
curl -X POST "https://api.lynkow.com/storefront/{siteId}/analytics/events" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "3f2b8c1e-7a4d-4e9b-9c2a-5d6e7f8a9b0c",
    "visitor_id": "9b1f4c7e2a6d8350",
    "event_type": "pageview",
    "page_path": "/pricing",
    "event_time": "2026-05-12T14:32:18.000Z"
  }'
```

```javascript
fetch(`https://api.lynkow.com/storefront/${siteId}/analytics/events`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  credentials: 'include',
  keepalive: true,
  body: JSON.stringify({
    session_id: sessionId,
    visitor_id: visitorId,
    event_type: 'pageview',
    page_path: location.pathname,
    event_time: new Date().toISOString(),
  }),
})
```

---