Artist Analytics Endpoint
Route
GET /wp-json/extrachill/v1/artists/{id}/analytics
Purpose
Retrieve link page performance analytics for an artist, including total views, clicks, and click data for top links. This endpoint provides artist-centric analytics replacing the legacy /analytics/link-page endpoint.
Permission
- GET: Readable only by artist owner or admin using
ec_can_manage_artist()permission check
GET Request
Artist ID is extracted from the URL path. Optional date range parameter controls the analytics window.
Query Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
date_range |
integer | No | 30 | Number of days of analytics to retrieve |
GET Response
{
"artist_id": 123,
"date_range": 30,
"total_views": 1250,
"total_clicks": 342,
"top_links": [
{
"url": "https://open.spotify.com/artist/abc123",
"clicks": 156
},
{
"url": "https://instagram.com/artist",
"clicks": 98
},
{
"url": "https://youtube.com/@artist",
"clicks": 67
}
]
}
Error Codes
| Code | Status | Description |
|---|---|---|
missing_permission |
403 | Current user cannot manage this artist |
invalid_artist_id |
404 | Artist post not found |
no_link_page |
404 | Artist has not created a link page |
database_error |
500 | Failed to retrieve analytics data |
Implementation Notes
- Analytics data is retrieved from the platform’s analytics tracking system
- The endpoint uses
extrachill_get_link_page_analyticsfilter hook for data retrieval, allowing plugins to provide custom analytics providers - The
date_rangeparameter is flexible and accepts any positive integer for days - Click data is ordered by highest click count first (descending)
- The
top_linksarray includes both section links and social links - Views represent page views of the link page itself
- Clicks represent clicks on individual links from the link page
Related Endpoints
GET /artists/{id}– Get core artist dataGET/PUT /artists/{id}/links– Manage link page presentationPOST /analytics/click– Track clicks including link page links (called by frontend)POST /analytics/view– Track views (used by extrachill-analytics for post views; link-page view tracking depends on the requesting surface)
Usage Examples
Get Analytics for Last 30 Days
curl -X GET "http://site.local/wp-json/extrachill/v1/artists/123/analytics"
Get Analytics for Last 90 Days
curl -X GET "http://site.local/wp-json/extrachill/v1/artists/123/analytics?date_range=90"
Get Analytics for Last 7 Days
curl -X GET "http://site.local/wp-json/extrachill/v1/artists/123/analytics?date_range=7"
Data Flow
- A requesting surface records views (commonly via
POST /analytics/view) when appropriate - A requesting surface records clicks via
POST /analytics/click(e.g.click_type: 'link_page_link') - Artist dashboard calls this endpoint to display analytics
- Data aggregation is handled by the analytics provider via the filter hook