Clickport
Start free trial

API Reference

The Clickport API lets you query your analytics data programmatically, send events from your server, and access realtime visitor counts. All endpoints require authentication via API key.

Authentication

Every API request must include your site's API key. You can find and manage your API keys in Settings → API Keys in your dashboard.

Pass the key in the x-api-key HTTP header:

curl https://clickport.io/api/query \
  -H "x-api-key: ck_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"metrics": ["visitors"], "period": "30d"}'

API keys start with ck_ and are scoped to a single site. Each key has read and tracker permissions, allowing you to query data and send events.

Keep your API key secret. Do not expose it in client-side JavaScript, public repositories, or browser-accessible code. Use it only in server-side applications.

Base URL

All API endpoints use the base URL:

https://clickport.io/api

Rate limits

The event ingestion endpoint (/api/event) is rate-limited to 60 requests per minute per IP address. When the limit is exceeded, events are silently dropped (the response still returns 200). Query endpoints do not have a per-request rate limit but are subject to fair use.

Stats API

Query your analytics data with flexible metrics, dimensions, filters, and date ranges.

POST /api/query

Request body

Parameter
Required
Description
metrics
optional
Array of metrics to return. Default: ["visitors"]
dimensions
optional
Array of dimensions to group by. Omit for aggregate totals.
period
optional
Predefined period. Default: "today"
date_range
optional
Custom date range: {"start": "2026-03-01", "end": "2026-03-31"}. End date is exclusive.
filters
optional
Array of filter objects: [{"dimension": "country", "operator": "is", "value": "DE"}]
order_by
optional
Metric to sort by. Default: first metric.
order_dir
optional
"asc" or "desc". Default: "desc"
limit
optional
Max rows to return. Default: 100
offset
optional
Number of rows to skip (pagination). Default: 0
timezone
optional
IANA timezone for date calculations. Default: "UTC"
include_comparison
optional
Include previous period comparison. Default: false

Available metrics

Available dimensions

Periods

Filter operators

Example: Aggregate query

Get total visitors, pageviews, and bounce rate for the last 30 days:

curl -X POST https://clickport.io/api/query \
  -H "x-api-key: ck_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": ["visitors", "pageviews", "bounce_rate"],
    "period": "30d"
  }'

Response:

{
  "results": {
    "visitors": 4821,
    "pageviews": 12493,
    "bounce_rate": 42
  }
}

Example: Breakdown query

Get top pages by visitors for a custom date range, filtered to Germany:

curl -X POST https://clickport.io/api/query \
  -H "x-api-key: ck_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": ["visitors", "pageviews", "avg_scroll"],
    "dimensions": ["page"],
    "date_range": {"start": "2026-03-01", "end": "2026-03-31"},
    "filters": [{"dimension": "country", "operator": "is", "value": "DE"}],
    "limit": 10,
    "timezone": "Europe/Berlin"
  }'

Response:

{
  "results": [
    { "page": "/", "visitors": 312, "pageviews": 487, "avg_scroll": 65 },
    { "page": "/pricing", "visitors": 198, "pageviews": 214, "avg_scroll": 78 },
    { "page": "/blog/privacy", "visitors": 145, "pageviews": 152, "avg_scroll": 82 }
  ]
}

Example: Time series

Get daily visitor counts for the last 7 days:

curl -X POST https://clickport.io/api/query \
  -H "x-api-key: ck_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "metrics": ["visitors", "pageviews"],
    "dimensions": ["date"],
    "period": "7d"
  }'

Response:

{
  "results": [
    { "date": "2026-03-25", "visitors": 183, "pageviews": 421 },
    { "date": "2026-03-26", "visitors": 201, "pageviews": 467 },
    { "date": "2026-03-27", "visitors": 195, "pageviews": 442 }
  ]
}

Events API

Send events from your server. Use this for server-side tracking, mobile apps, or any environment where the JavaScript tracker is not available.

POST /api/event

Request body

Parameter
Required
Description
type
optional
Event type: "pageview", "custom", "click", "form". Default: "pageview"
url
required
Full page URL: "https://yoursite.com/page"
referrer
optional
Referring URL
name
optional
Event name (for custom events). Example: "Signup"
utm_source
optional
Campaign source
utm_medium
optional
Campaign medium
utm_campaign
optional
Campaign name
screen_width
optional
Viewport width in pixels (for device classification)
timezone
optional
Visitor timezone. Default: "UTC"
revenue_amount
optional
Revenue amount (numeric). For ecommerce tracking.
revenue_currency
optional
Currency code. Example: "USD", "EUR"
meta_keys
optional
Array of custom property names. Max 30 keys.
meta_values
optional
Array of values corresponding to meta_keys. Max 2000 chars each.
User-Agent header required. Include a valid User-Agent header with your request. Clickport uses it for browser/OS detection and to filter bots. Requests with missing or bot-like User-Agents may be rejected.

Example: Track a pageview

curl -X POST https://clickport.io/api/event \
  -H "x-api-key: ck_your_key" \
  -H "Content-Type: application/json" \
  -H "User-Agent: Mozilla/5.0 ..." \
  -d '{
    "type": "pageview",
    "url": "https://yoursite.com/pricing",
    "referrer": "https://google.com/"
  }'

Response:

{
  "success": true,
  "session_id": 48291,
  "page_visit_id": "a1b2c3d4"
}

Example: Track a custom event with revenue

curl -X POST https://clickport.io/api/event \
  -H "x-api-key: ck_your_key" \
  -H "Content-Type: application/json" \
  -H "User-Agent: Mozilla/5.0 ..." \
  -d '{
    "type": "custom",
    "name": "Purchase",
    "url": "https://yoursite.com/checkout/complete",
    "revenue_amount": 49.99,
    "revenue_currency": "USD",
    "meta_keys": ["plan", "interval"],
    "meta_values": ["pro", "annual"]
  }'

Privacy and processing

Realtime API

Get the number of currently active visitors on your site.

GET /api/realtime
curl https://clickport.io/api/realtime \
  -H "x-api-key: ck_your_key"

Response:

{
  "count": 7,
  "visitors": [
    {
      "session_id": 91823,
      "entry_page": "/",
      "exit_page": "/pricing",
      "pageviews": 3,
      "duration": 124,
      "source": "google",
      "country": "DE",
      "city": "Berlin",
      "device": "Desktop",
      "browser": "Chrome",
      "os": "macOS",
      "scroll": 72
    }
  ]
}

Returns up to 20 currently active visitors (active within the last 5 minutes). Each visitor includes their session details, current page, traffic source, location, and engagement data.

Goals API

Retrieve goal conversion data for your site.

GET /api/goals
Parameter
Description
start_date
Start date (YYYY-MM-DD). Required.
end_date
End date, exclusive (YYYY-MM-DD). Required.
timezone
IANA timezone. Default: "UTC"
curl "https://clickport.io/api/goals?start_date=2026-03-01&end_date=2026-03-31" \
  -H "x-api-key: ck_your_key"

Response:

{
  "goals": [
    {
      "id": 1,
      "name": "Contact Form",
      "type": "form",
      "visitors": 84,
      "submissions": 91
    },
    {
      "id": 2,
      "name": "Purchase",
      "type": "custom",
      "visitors": 37,
      "events": 42,
      "total_revenue": 1849.50
    }
  ]
}

Convenience endpoints

These GET endpoints return pre-formatted breakdowns for common dimensions. All accept start_date and end_date as query parameters.

Example

curl "https://clickport.io/api/pages?start_date=2026-03-01&end_date=2026-03-31" \
  -H "x-api-key: ck_your_key"

Error responses

The API returns standard HTTP status codes:

Error responses include a JSON body:

{
  "error": "Unauthorized",
  "message": "Invalid API key"
}