Appearance
Link Totals
link_totals returns lifetime view and clickthrough counts for every link belonging to an artist, in one call and with no date range. It is the fastest way to populate a links list with performance numbers.
Request
graphql
query LinkTotals($artist_id: String!) {
link_totals(artist_id: $artist_id) {
data
}
}Variables:
json
{ "artist_id": "3aad8009-a307-4429-a586-8b3dbe39cdda" }Arguments
| Argument | Type | Description |
|---|---|---|
artist_id | String! | The artist whose links to total. Note this is String!, not uuid! — the value is the same UUID. |
Response
link_totals returns a single data field holding a JSON-encoded string. Parse it before use.
json
{
"data": {
"link_totals": {
"data": "[{\"link_id\":\"9c4b2f10-...\",\"clicks\":2043,\"views\":4821},{\"link_id\":\"7d1a55e2-...\",\"clicks\":118,\"views\":392}]"
}
}
}js
const totals = JSON.parse(response.data.link_totals.data);
// [{ link_id: "9c4b2f10-...", clicks: 2043, views: 4821 }, ...]| Field | Description |
|---|---|
link_id | The link's ID. |
views | Lifetime page views. |
clicks | Lifetime destination clicks. |
Links with no recorded activity may be absent from the array. Treat a missing link_id as zero rather than assuming one entry per link.
Joining with link metadata
link_totals returns IDs and numbers only. Fetch the links in the same round trip and join client-side:
graphql
query LinksWithTotals($artist_id: uuid!, $artist_id_str: String!) {
links(where: { artist_id: { _eq: $artist_id } }, order_by: { created_at: desc }) {
id
domain
path
title
image
}
link_totals(artist_id: $artist_id_str) {
data
}
}Pass the same UUID for both variables — one typed uuid, one typed String.
Or skip it entirely
Links carry running lifetime counters directly, which avoids the JSON parse and the join:
graphql
query LinksWithCounters($artist_id: uuid!) {
links(
where: { artist_id: { _eq: $artist_id } }
order_by: { clickthroughs_total: desc }
) {
id
path
title
views_total
clickthroughs_total
}
}This is cheaper than link_totals and sortable server-side, so prefer it unless you specifically need the analytics store's own numbers. The two can differ slightly: the column counters are maintained by the application, while link_totals is computed from the raw event stream.
Comparison
| Field | Scope | Date range | Shape |
|---|---|---|---|
views_total / clickthroughs_total | One link | Lifetime | Typed Int columns |
link_totals | All of an artist's links | Lifetime | JSON string |
artist_statistics | All of an artist's links | Yes | Daily series |
link_statistics | One link | Yes | Daily series plus breakdowns |