> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dashlink.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics

> How click data is organised and which endpoint answers which question.

Every redirect is recorded with what could be derived from the request: time, approximate location, device, browser, referrer, and any UTM parameters on the destination. The analytics endpoints read that back.

## Three scopes

Endpoints are named for what they cover, and the prefix tells you which.

| Prefix | Covers | Identified by |
| - | - | - |
| `get_org_*` | Everything in the organization | Nothing — it is your whole account |
| `get_campaign_*` | One campaign | `name` or `campaign_id` |
| `get_shortlink_*` | One link | `name` |

Within each scope the same four shapes recur:

> [card] KPIs
>
> `get_org_kpis`, `get_campaign_kpis` — headline totals plus change against the preceding period.

> [card] Breakdowns
>
> `*_metrics_aggregation` — clicks grouped by one dimension, paginated. See [Metrics](https://docs.dashlink.ai/guides/analytics/metrics.md).

> [card] Time series
>
> `*_clicks_users_over_time`, `*_clicks_by_hour` — clicks per bucket.

> [card] Reports
>
> `download_*_analytics_report*` — the same data as a file. See [Reports](https://docs.dashlink.ai/guides/analytics/reports.md).

## A first call

```bash cURL theme={null}
curl -X GET "https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31" \
  -H "X-API-Key: $DASHLINK_API_KEY"
```

```javascript Node.js theme={null}
const response = await fetch("https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31", {
  headers: { "X-API-Key": process.env.DASHLINK_API_KEY },
});
const payload = await response.json();
```

```python Python theme={null}
import os
import requests

response = requests.get(
    'https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31',
    headers={'X-API-Key': os.environ["DASHLINK_API_KEY"]},
)
payload = response.json()
```

```go Go theme={null}
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	endpoint0 := "https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31"
	req0, err0 := http.NewRequest("GET", endpoint0, nil)
	if err0 != nil {
		panic(err0)
	}
	req0.Header.Set("X-API-Key", os.Getenv("DASHLINK_API_KEY"))
	resp0, err0b := http.DefaultClient.Do(req0)
	if err0b != nil {
		panic(err0b)
	}
	defer resp0.Body.Close()
	body0, _ := io.ReadAll(resp0.Body)
	fmt.Println(string(body0))
}

```

```ruby Ruby theme={null}
require "net/http"
require "json"
require "uri"

uri0 = URI("https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31")
request0 = Net::HTTP::Get.new(uri0)
request0["X-API-Key"] = ENV.fetch("DASHLINK_API_KEY")
response0 = Net::HTTP.start(uri0.hostname, uri0.port, use_ssl: true) do |http|
  http.request(request0)
end
payload0 = JSON.parse(response0.body)
```

```php PHP theme={null}
<?php
$ch0 = curl_init('https://api.dashlink.ai/api/v1/analytics/get_org_kpis?date_from=2026-01-01&date_to=2026-01-31');
curl_setopt($ch0, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch0, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch0, CURLOPT_HTTPHEADER, [
    "X-API-Key: " . getenv("DASHLINK_API_KEY"),
]);
$payload0 = json_decode(curl_exec($ch0), true);
curl_close($ch0);
```

`date_from` and `date_to` are `YYYY-MM-DD`. Most endpoints require both; a few time-series endpoints default to the last thirty days if you omit them.

## Things that will surprise you otherwise

> [accordion] Your date range may be moved forward
>
> Plans have a retention window. Ask for more history than yours allows and the range is silently clamped to the floor — the response tells you when this happened. See [Retention](https://docs.dashlink.ai/guides/analytics/retention.md).

> [accordion] Some breakdowns come back locked
>
> City, region, device, browser, operating system and the UTM dimensions are plan-gated. On a plan without them you get sample rows and `"locked": true` rather than an error. See [Metrics](https://docs.dashlink.ai/guides/analytics/metrics.md).

> [accordion] Filters change which engine answers
>
> Simple queries are served from pre-aggregated rollups and are fast. Certain filters force a raw scan, and one endpoint — `get_org_metrics_batch` — refuses them outright. See [Filtering](https://docs.dashlink.ai/guides/analytics/filtering.md).

> [accordion] Numbers move for a few minutes
>
> Rollups are not instantaneous. A click you just generated may not appear immediately, so do not write a test that creates a link, clicks it, and asserts a count in the same breath.

## Time zones

Pass `timezone` — an IANA name such as `America/New_York` — and day boundaries are computed there. Omit it and you get UTC. Worth setting explicitly: "yesterday" in UTC is not yesterday for most of your customers, and a daily series bucketed in the wrong zone shifts every peak.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.