Goals & Revenue

The Goals and Revenue API lets you read goal conversion data, create server-side goal events, view revenue metrics, and record payment transactions. These endpoints are essential for tracking conversions and attributing revenue to visitors.

Info

POST endpoints (/api/v1/goals and /api/v1/payments) require an API key with Read & Write permissions. Read-only API keys will receive a 403 Forbidden response.

Goals

GET /api/v1/goals

Returns a list of all goals for your website with conversion statistics for the given date range. Each goal includes the number of unique visitors who completed it, total completions, and the conversion rate.

ParameterTypeRequiredDescription
site_idstringYesYour website ID
startstringNoISO 8601 start date. Default: 30 days ago
endstringNoISO 8601 end date. Default: now
timezonestringNoIANA timezone. Default: UTC
limitnumberNoResults limit, 1–1000. Default: 100
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://datasaas.co/api/v1/goals?site_id=ds_abc123&start=2026-03-01&end=2026-03-26"
{
  "results": [
    {
      "goal_name": "signup",
      "unique_visitors": 340,
      "completion_count": 412,
      "conversion_rate": 0.027
    },
    {
      "goal_name": "purchase",
      "unique_visitors": 85,
      "completion_count": 92,
      "conversion_rate": 0.007
    },
    {
      "goal_name": "newsletter_subscribe",
      "unique_visitors": 210,
      "completion_count": 210,
      "conversion_rate": 0.017
    }
  ],
  "meta": {
    "site_id": "ds_abc123",
    "start": "2026-03-01T00:00:00Z",
    "end": "2026-03-26T23:59:59Z"
  }
}

POST /api/v1/goals

Creates a server-side goal completion event. Use this to track conversions that happen on your backend (e.g., successful payments, account activations) rather than in the browser. Requires an API key with write scope.

FieldTypeRequiredDescription
site_idstringYesYour website ID (query parameter)
namestringYesGoal name (e.g., signup, purchase)
visitor_idstringYesThe visitor to attribute this goal to
urlstringNoURL where the goal occurred
metadataobjectNoArbitrary key-value data to attach to the event
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "signup", "visitor_id": "v_8f3a2b1c", "url": "https://app.example.com/welcome", "metadata": {"plan": "pro"}}' \
  "https://datasaas.co/api/v1/goals?site_id=ds_abc123"
{
  "results": {
    "created": true,
    "goal_name": "signup"
  },
  "meta": {
    "site_id": "ds_abc123"
  }
}

GET /api/v1/goals/:name/completions

Returns a list of individual completions for a specific goal. Each completion includes the visitor who completed it, along with geographic and device information. The :name parameter is the goal name (e.g., signup).

ParameterTypeRequiredDescription
site_idstringYesYour website ID
:namestringYesGoal name (URL path parameter)
startstringNoISO 8601 start date. Default: 30 days ago
endstringNoISO 8601 end date. Default: now
timezonestringNoIANA timezone. Default: UTC
limitnumberNoResults limit, 1–1000. Default: 100
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://datasaas.co/api/v1/goals/signup/completions?site_id=ds_abc123&start=2026-03-01&end=2026-03-26&limit=10"
{
  "results": [
    {
      "visitor_id": "v_8f3a2b1c",
      "completed_at": "2026-03-25T14:05:00Z",
      "source": "google.com",
      "country": "United States",
      "city": "San Francisco",
      "browser": "Chrome",
      "os": "macOS",
      "device_type": "desktop"
    },
    {
      "visitor_id": "v_9d4c3e2f",
      "completed_at": "2026-03-24T09:30:00Z",
      "source": "twitter.com",
      "country": "Germany",
      "city": "Berlin",
      "browser": "Firefox",
      "os": "Linux",
      "device_type": "desktop"
    }
  ],
  "meta": {
    "site_id": "ds_abc123",
    "goal_name": "signup",
    "start": "2026-03-01T00:00:00Z",
    "end": "2026-03-26T23:59:59Z",
    "limit": 10
  }
}

Revenue

GET /api/v1/revenue

Returns an overview of revenue metrics for your website within the given date range, including total revenue, monthly recurring revenue (MRR), and conversion rate. All amounts are in dollars (not cents).

ParameterTypeRequiredDescription
site_idstringYesYour website ID
startstringNoISO 8601 start date. Default: 30 days ago
endstringNoISO 8601 end date. Default: now
timezonestringNoIANA timezone. Default: UTC
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://datasaas.co/api/v1/revenue?site_id=ds_abc123&start=2026-03-01&end=2026-03-26"
{
  "results": {
    "total_revenue": 24500.00,
    "mrr": 8200.00,
    "conversion_rate": 0.032
  },
  "meta": {
    "site_id": "ds_abc123",
    "start": "2026-03-01T00:00:00Z",
    "end": "2026-03-26T23:59:59Z",
    "timezone": "UTC"
  }
}
Note

Revenue amounts are returned in dollars, not cents. For example, 24500.00 represents $24,500.00 USD.

GET /api/v1/revenue/timeseries

Returns revenue data broken down over time by the specified granularity. Each data point includes new revenue and refund amounts.

ParameterTypeRequiredDescription
site_idstringYesYour website ID
startstringNoISO 8601 start date. Default: 30 days ago
endstringNoISO 8601 end date. Default: now
timezonestringNoIANA timezone. Default: UTC
granularitystringNoOne of hour, day, week, month. Default: day
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://datasaas.co/api/v1/revenue/timeseries?site_id=ds_abc123&start=2026-03-01&end=2026-03-26&granularity=day"
{
  "results": [
    { "period": "2026-03-01", "new_revenue": 1200.00, "refund_revenue": 0.00 },
    { "period": "2026-03-02", "new_revenue": 850.00, "refund_revenue": 49.99 },
    { "period": "2026-03-03", "new_revenue": 1500.00, "refund_revenue": 0.00 }
  ],
  "meta": {
    "site_id": "ds_abc123",
    "start": "2026-03-01T00:00:00Z",
    "end": "2026-03-26T23:59:59Z",
    "granularity": "day"
  }
}

POST /api/v1/payments

Creates a payment record and attributes it to a visitor. Use this to manually record payments from custom billing systems or providers not natively supported. Requires an API key with write scope.

FieldTypeRequiredDescription
site_idstringYesYour website ID (query parameter)
visitor_idstringYesThe visitor to attribute payment to
amountnumberYesPayment amount in dollars (e.g., 99.00)
currencystringYesISO 4217 currency code (e.g., USD)
transaction_idstringYesYour unique transaction identifier
payment_typestringNoOne of one_time, recurring, refund. Default: one_time
product_namestringNoName of the product or plan
paid_atstringNoISO 8601 timestamp. Default: now
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"visitor_id": "v_8f3a2b1c", "amount": 99.00, "currency": "USD", "transaction_id": "txn_abc123", "payment_type": "recurring", "product_name": "Pro Plan"}' \
  "https://datasaas.co/api/v1/payments?site_id=ds_abc123"
{
  "results": {
    "created": true,
    "transaction_id": "txn_abc123"
  },
  "meta": {
    "site_id": "ds_abc123"
  }
}