WysLeap
WysLeap Docs

Track a custom event

POST
/api/telemetry/event

Records a custom event: purchases, sign-ups, button clicks, or any other interaction that matters to you. Use Title Case for event names, e.g. Sign Up Success, not sign_up_success.

This is the endpoint the tracker uses in the browser (WysLeap.trackEvent); to send events from a server, use POST /api/v1/events with a secret key.

Authorization

ApiKeyHeader
headerX-API-Key<token>

The site API key from Site Settings, in the X-API-Key header or as _apiKey in the JSON body. It ships in your tracker snippet, so it isn't a secret: the endpoints also check the page's domain against your allowed domains.

Request Body

application/json
  1. body
siteId*string

Your site identifier.

eventName*string

Event name in Title Case (e.g. "Purchase Completed").

eventData?

Any JSON-serializable metadata for the event.

visitorId?string

Visitor ID to associate the event with.

sessionId?string

Session ID to associate the event with.

pageUrl?string

URL where the event occurred.

_apiKey?string

Site API key (or send it in the X-API-Key header).

Response Body

Accepted. stored is false when the hit was dropped, e.g. no consent for an EU/EEA, UK or Swiss visitor.

application/json
  1. response
success?boolean
Defaulttrue
stored?boolean

false when the hit was not stored, e.g. a visitor in the EU/EEA, UK or Switzerland without consent.

reason?string

Why the hit was not stored, e.g. consent_required.

Example Request
curl -X POST https://wysleap.com/api/telemetry/event \  -H "Content-Type: application/json" \  -d '{    "siteId": "your-site-id",    "eventName": "Purchase Completed",    "eventData": {      "productId": "prod_123",      "productName": "Premium Plan",      "currency": "USD"    },    "visitorId": "vis_abc123",    "pageUrl": "https://example.com/checkout/success",    "_apiKey": "your-api-key"  }'
Example Response
{  "success": true}