Analytics API
Link analytics
GET /api/v1/links/{shortCode}/analytics reads metrics for a link. Keys require analytics:read; JWT callers must be authorized for the selected project. Supported parameters include period, startDate, endDate, compareStartDate and compareEndDate.
curl "$SLNK_API_URL/api/v1/links/SHORT_CODE/analytics?period=30d" \
--header "Authorization: Bearer $SLNK_API_KEY"
Use the returned metrics rather than deriving totals from a limited top-items list. Reporting days follow the project's server reporting contract; do not assume UTC calendar days. The current reporting zone is Africa/Casablanca, whose UTC offset can change during the year.
Leads, sales and revenue per link
The link analytics also report the conversions attributed to the link and to its channel variants. Conversions are declared with POST /api/v1/track/lead and /track/sale, passing the clickId (slnk_cid) of the click. Each confirmed conversion is allocated to the links of its journey by the attribution model; a conversion without touchpoint belongs to no link.
| Parameter | Values | Default |
|---|---|---|
model | last_touch, first_touch, linear, time_decay, position_based (case-insensitive) | last_touch |
curl "$SLNK_API_URL/api/v1/links/SHORT_CODE/analytics?period=30d&model=linear" \
--header "Authorization: Bearer $SLNK_API_KEY"
Fields added to current (and to comparison):
| Field | Meaning |
|---|---|
leads | Confirmed leads attributed to the link: sum of attribution weights. Fractional under linear, time_decay and position_based. |
sales | Confirmed sales attributed to the link, same rule. |
revenue | Attributed value of the sales in currency. |
currency | Reporting currency of the project (MAD, EUR or USD). Sales in another currency are left out of revenue. |
revenueByCurrency | Attributed sale value per currency, including the excluded currencies. |
conversionRate | (leads + sales) / totalClicks × 100, 2 decimals. Absent when the period has no click. |
attributionModel | Model used for the four figures above. |
Each timeSeries point also carries leads, sales and revenue for its day (conversions are dated by their conversion time). With compareStartDate and compareEndDate, changes adds the percentage change of leads, sales and revenue.
An unknown model answers 400 VALIDATION_ERROR.
Top links
GET /api/v1/analytics/top-links lists the links of the project ordered by clicks (limit 1 to 100, period 24h, 7d, 30d or 90d). Two optional parameters rank them by conversions:
| Parameter | Values | Default |
|---|---|---|
sortBy | clicks, leads, sales, revenue | clicks |
model | The five attribution models | last_touch |
Each item carries leads, sales, revenue and currency in addition to clickCount. A conversion sort ranks the limit × 5 most clicked links (500 at most) by the chosen figure, then by clicks. An unknown sortBy or model answers 400 VALIDATION_ERROR.
GET /api/v1/orgs/{orgId}/analytics/top-links keeps its order by clicks and adds the same four fields, attributed in last_touch, with revenue in the currency of each link's project.
The attribution reports (/api/v1/analytics/attribution/*, ROI report) count confirmed sales only: leads have no value and would lower the cost per conversion and the average value of a path.
Realtime summary
GET /api/v1/analytics/realtime/summary returns the current project's summary. It requires analytics:read for keys, appropriate user access for JWT and the relevant feature entitlement. Add X-Project-Id for a JWT request, not to override a key's bound project.
Treat 403 as an access/feature error, not an empty result. A 503 analytics dependency error also differs from a valid response with no activity. Ingestion acknowledgement and visibility in derived analytics can happen at different times.