Skip to main content
POST
Events

Track Events

Events represent user actions in your application. Use the Ingestion API to send events to Mixpanel for analysis.

Import Events

The Import API provides server-side event tracking with full validation and detailed error reporting.
string
required
Your Mixpanel project ID (required when using service account authentication)
string
default:"1"
When set to 1 (recommended), Mixpanel validates the batch and returns errors per event that failed.Options: 0 or 1
string
default:"application/json"
The content type of the request body.Options:
  • application/json: Standard JSON array
  • application/x-ndjson: Newline-delimited JSON
string
Compression method for the request body.Options: gzip

Request Body

string
required
The name of the event (e.g., “Signed Up”, “Purchase Complete”)
object
required
Event properties object

Example Request

Response

integer
HTTP status code (200 for success)
integer
Number of events successfully imported
string
Status message (“OK” for success)
array
Array of failed events (only present when strict=1 and some events failed)

Track Events (Client-Side)

The Track API is designed for client-side event tracking using your project token.
string
If set to 1, uses the IP address of the request to determine geolocation
string
If set to 1, returns a verbose JSON response instead of simple 1 or 0

Request Body

string
required
The name of the event
object
required
Event properties

Example Request

Response

Returns 1 for success, 0 for failure.

Best Practices

This ensures events aren’t duplicated if a request is retried:
The Import API provides:
  • Better validation and error reporting
  • More secure (credentials not exposed to clients)
  • Support for historical data imports
Send up to 2000 events per request:
Use clear, consistent naming:
  • Good: “Signed Up”, “Purchase Completed”, “Video Played”
  • Bad: “event1”, “action”, “e”
Add properties that help analyze the event:

Common Errors

Error: 'properties.time' is invalid: must be specified as seconds since epochSolution: Ensure timestamps are in seconds (not milliseconds) or milliseconds (with 13 digits)
Error: Various validation errorsSolution: Ensure all required fields are present:
  • event name
  • properties.distinct_id
  • properties.time
  • properties.$insert_id (for /import)
Error: request exceeds max limit of 2097152 bytesSolution:
  • Reduce batch size (max 2000 events)
  • Use gzip compression
  • Split into multiple requests