GET /tracking/performance/:programId

Retrieve daily performance aggregates and period-over-period trend metrics for a program

Returns daily aggregated metrics (clicks, leads, conversions, revenue, partners, commissions) for a program, along with period-over-period trend comparisons. This endpoint is used by the Affitor dashboard performance chart.


Endpoint

GET /api/tracking/performance/:programId


Authentication

Requests must be authenticated. The authenticated user must be an active workspace member of the requested program.

HeaderValue
AuthorizationSession token (Affitor dashboard session)

An unauthenticated request returns 401. A request from a user who is not a workspace member of the program returns 403.


Path Parameter

ParameterTypeRequiredDescription
programIdintegerYesID of the affiliate program

Query Parameters

ParameterTypeRequiredDescription
periodstringNoPreset time window. One of 7d, 30d, 90d, all. Defaults to 7d. Ignored when dateFrom and dateTo are provided.
dateFromstring (ISO 8601)NoStart of a custom date range. Must be used together with dateTo.
dateTostring (ISO 8601)NoEnd of a custom date range. Must be used together with dateFrom.

When dateFrom and dateTo are both present, the period parameter is ignored. The previous comparison period is automatically calculated as an equal-length window immediately before the custom range.


Response

HTTP 200 with the following shape:

{
  "data": [
    {
      "date": "2024-06-01",
      "period": "2024-06-01",
      "clicks": 42,
      "leads": 5,
      "conversions": 2,
      "revenue": 199.98,
      "partners": 1,
      "sales": 0,
      "commission": 20.00
    },
    {
      "date": "2024-06-02",
      "period": "2024-06-02",
      "clicks": 18,
      "leads": 2,
      "conversions": 0,
      "revenue": 0.00,
      "partners": 0,
      "sales": 0,
      "commission": 0.00
    }
  ],
  "metrics": {
    "totalClicks": 60,
    "totalLeads": 7,
    "totalConversions": 2,
    "totalRevenue": 199.98,
    "conversionRate": 3.33,
    "averageOrderValue": 99.99,
    "totalPartners": 1,
    "totalSales": 2,
    "totalPartnersCommission": 20.00,
    "clicksTrend": { "trend": 15.0, "trendDirection": "up" },
    "leadsTrend": { "trend": 0, "trendDirection": "stable" },
    "conversionsTrend": { "trend": 100, "trendDirection": "up" },
    "revenueTrend": { "trend": 100, "trendDirection": "up" },
    "partnersTrend": { "trend": 0, "trendDirection": "stable" },
    "salesTrend": { "trend": 100, "trendDirection": "up" },
    "commissionTrend": { "trend": 100, "trendDirection": "up" }
  },
  "meta": {
    "period": "7d",
    "dateFrom": "2024-05-25T00:00:00.000Z",
    "dateTo": "2024-06-01T23:59:59.999Z",
    "previousPeriod": {
      "dateFrom": "2024-05-18T00:00:00.000Z",
      "dateTo": "2024-05-24T23:59:59.999Z"
    }
  }
}

data array

Each entry covers one calendar day within the requested range. Days with no activity are included with all counts set to 0.

FieldTypeDescription
datestring (YYYY-MM-DD)Calendar date for the row
periodstring (YYYY-MM-DD)Same value as date
clicksintegerReal (non-test) affiliate click events on this date
leadsintegerCustomers whose signup_date falls on this date and whose status is lead or conversion
conversionsintegerCustomers whose first_purchase_date falls on this date and whose status is conversion
revenuenumberTotal sale revenue in dollars from paid sale events on this date
partnersintegerPartner-program records created on this date
salesintegerAlways 0 (Affitor Pay checkout removed; revenue comes from sale events)
commissionnumberTotal commission amount in dollars for commissions created on this date

metrics object

Aggregated totals and trend comparisons for the full requested period.

FieldTypeDescription
totalClicksintegerTotal real click events in the period
totalLeadsintegerTotal lead-status customers in the period
totalConversionsintegerTotal conversion-status customers in the period
totalRevenuenumberTotal revenue in dollars (rounded to 2 decimal places)
conversionRatenumber(totalConversions / totalClicks) * 100, rounded to 2 decimal places. 0 if no clicks.
averageOrderValuenumbertotalRevenue / totalConversions, rounded to 2 decimal places. 0 if no conversions.
totalPartnersintegerTotal partner-program records created in the period
totalSalesintegerTotal paid sale events in the period
totalPartnersCommissionnumberTotal commission amount in dollars (rounded to 2 decimal places)
clicksTrendobjectTrend vs previous equal-length period (see below)
leadsTrendobjectTrend for leads
conversionsTrendobjectTrend for conversions
revenueTrendobjectTrend for revenue
partnersTrendobjectTrend for partners
salesTrendobjectTrend for sale count
commissionTrendobjectTrend for commission amount

Each trend object:

FieldTypeDescription
trendnumberAbsolute percentage change, rounded to 1 decimal place
trendDirectionstring"up", "down", or "stable"

When the previous period value is 0 and the current value is greater than 0, trend is 100 and trendDirection is "up". When both are 0, trend is 0 and trendDirection is "stable".

meta object

FieldTypeDescription
periodstringThe period query param value used (or "all" for default)
dateFromstring (ISO 8601)Actual start of the current period used in the query
dateTostring (ISO 8601)Actual end of the current period used in the query
previousPeriod.dateFromstring (ISO 8601)Start of the comparison period
previousPeriod.dateTostring (ISO 8601)End of the comparison period

Errors

StatusWhen
401 UnauthorizedNo authenticated session
403 ForbiddenAuthenticated user is not an active workspace member of programId
404 Not FoundProgram with the given programId does not exist
500 Internal Server ErrorUnexpected server error
Edit on GitHub
© 2026 Affitor