pex

Analytics API

Query aggregated analytics, attribution data, and per-connector metrics. All endpoints require authentication.

Dashboard Summary

GET/api/analytics/summary

Get high-level analytics for the dashboard overview

ParameterTypeDescription
periodstringTime period: 7d, 30d, 90d, or custom. Defaults to 30d.
fromstringStart date (ISO 8601) for custom period
tostringEnd date (ISO 8601) for custom period
curl "https://your-instance.com/api/analytics/summary?period=30d" \ -H "x-api-key: apex_key_abc123"

Returns aggregated metrics:

{
  "visitors": 12450,
  "leads": 342,
  "conversions": 89,
  "conversionRate": 0.026,
  "topChannels": [
    { "channel": "organic_search", "visitors": 5200, "conversions": 42 },
    { "channel": "paid_search", "visitors": 3100, "conversions": 28 }
  ],
  "period": { "from": "2025-01-01", "to": "2025-01-31" }
}

Attribution Summary

GET/api/attribution/summary

Get multi-touch attribution data across channels

ParameterTypeDescription
modelstringAttribution model: first_touch, last_touch, linear, or position_based. Defaults to position_based.
periodstringTime period: 7d, 30d, 90d. Defaults to 30d.
curl "https://your-instance.com/api/attribution/summary?model=linear&period=30d" \ -H "x-api-key: apex_key_abc123"

Returns per-channel attribution with credited conversions:

{
  "model": "linear",
  "channels": [
    { "channel": "organic_search", "creditedConversions": 34.5, "revenue": 12400 },
    { "channel": "paid_search", "creditedConversions": 22.0, "revenue": 8800 },
    { "channel": "email", "creditedConversions": 15.5, "revenue": 6200 }
  ]
}

Tip

Use position_based (the default) for a balanced view that credits both the first and last touchpoints more heavily, with remaining credit distributed evenly across middle touches.

Metrics Overview

GET/api/metrics

Get aggregated metrics across all connectors

curl "https://your-instance.com/api/metrics" \ -H "x-api-key: apex_key_abc123"

Connector Metrics

GET/api/metrics/:connectorType

Get metrics for a specific connected platform

ParameterTypeDescription
connectorTyperequiredstringConnector type: google_ads, meta_ads, linkedin_ads, etc. (path parameter)
periodstringTime period: 7d, 30d, 90d. Defaults to 30d.
curl "https://your-instance.com/api/metrics/google_ads?period=30d" \ -H "x-api-key: apex_key_abc123"

Returns platform-specific metrics. Fields vary by connector type:

{
  "connectorType": "google_ads",
  "spend": 4500.00,
  "impressions": 125000,
  "clicks": 3100,
  "conversions": 28,
  "cpa": 160.71,
  "roas": 2.8,
  "campaigns": [
    { "name": "Brand Search", "spend": 1200, "conversions": 15 },
    { "name": "Competitor Keywords", "spend": 3300, "conversions": 13 }
  ]
}