Tracker
Server-side Events

Server-side Events Tracking

This guide describes how to track events directly from your server. This is useful for backend processes, payment confirmations, or any action that doesn't happen in the user's browser.

Prerequisites

  • Tracking Setup — Server-side tracking works only when tracking is already set up for your domain (see Tracking Code Setup)
  • API Token — You need a customerscore-key (API token) generated in your Customerscore application under the API settings section
  • Tracker Key — You need your public trackerKey (e.g., CS-ABCD1), which can be found in your app settings

Authentication

You need to authenticate your requests using the customerscore-key in the request header. Keep this token secret!

Content-Type: application/json
customerscore-key: "your-generated-key"

Endpoint

MethodURL
POSThttps://api.customerscore.io/api/tracker/track

Rate Limiting

Maximum of 200 requests per minute. If the limit is exceeded, the response will be:

  • HTTP status code: 429 Too Many Requests
  • Header: Retry-After — number of seconds to wait before retrying

Request Body

You can send multiple events (up to 100 events) in a single request. Maximum request body size is limited to 5 MB.

Example Request

curl -X POST "https://api.customerscore.io/api/tracker/track" \
  -H "Content-Type: application/json" \
  -H "customerscore-key: your-generated-key" \
  -d '{
    "trackerKey": "CS-ABCD1",
    "events": [
      {
        "name": "my-event-name",
        "timestamp": 1712123456789,
        "identification": {
          "customer": "cus_456",
          "contact": "con_123"
        },
        "data": {
          "customer": { "my-value": "184" },
          "contact": { "email": "thomas@example.com" }
        }
      }
    ]
  }'

Full Request Body Example

{
  "trackerKey": "CS-ABCD1",
  "events": [
    {
      "name": "my-event-name",
      "timestamp": 1712123456789,
      "identification": {
        "customer": "cus_456",
        "contact": "con_123"
      },
      "data": {
        "customer": { "my-value": "184" },
        "contact": { "email": "thomas@example.com" }
      }
    },
    {
      "name": "your-event-name",
      "timestamp": 1712123456789,
      "identification": {
        "customer": "cus_456",
        "contact": "con_789"
      },
      "data": {
        "customer": { "my-value": "345" },
        "contact": { "email": "peter@example.com", "contact_name": "Peter" }
      }
    }
  ]
}

Field Descriptions

The request body requires a trackerKey and an array of events.

FieldTypeRequiredDescription
trackerKeystringYesYour public tracker key (e.g., CS-ABCD1)
eventsarrayYesA list of event objects to track. Limit is 100 events per request

Event Object Structure

Each object within the events array must include the following attributes:

FieldTypeRequiredDescription
namestringYesThe name of the event (e.g., subscription_upgraded)
timestampnumberYesThe time the event occurred, in milliseconds (Unix timestamp)
identificationobjectYesIdentifies the user associated with the event
dataobjectNoAdditional properties to update or associate with the event

Identification Object

FieldTypeRequiredDescription
customerstringYesThe external ID of the customer
contactstringNoThe external ID of the contact

Data Object

FieldTypeRequiredDescription
customerobjectNoKey-value pairs of attributes to update on the customer level
contactobjectNoKey-value pairs of attributes to update on the contact level (e.g., email, contact_name)

Response Codes

CodeDescription
200The events have been successfully received and forwarded for processing
400Bad request (e.g., missing required fields, invalid JSON)
401Unauthorized - Missing or invalid customerscore-key in the header
403Forbidden - The key does not have permission to perform this action
405Method Not Allowed - Only POST is accepted
429Too Many Requests - Rate limit exceeded