Analytics

Get link analytics

Click analytics for a single link: totals plus breakdowns by country, device, browser, referrer, and operating system. Requires a plan with Analytics API access (Advanced plan or above).

GET https://u2l.ai/api/v1/analytics/{domain}/{slug}

Authorizations

Authorizationstringrequired

Bearer authentication header of the form Bearer <token>, where <token> is your U2L API key (u2l_live_...). Create one in the dashboard under Settings > API.

Path Parameters

domainstringrequired

The link's domain (e.g. u.gy or u2l.ai).

slugstringrequired

The link's slug (the part after the domain).

Query Parameters

timeRangeinteger

Number of days to include in clicksInRange and the breakdowns. Use 0 for all time. Defaults to 30.

Response 200

totalClicksinteger

All-time clicks.

clicksInRangeinteger

Clicks within timeRange.

clicksTodayinteger
clicksThisWeekinteger
timeRangeinteger

The requested range in days (0 = all time).

countriesobject[]
countries[].countrystring
countries[].clicksinteger
devicesobject

Clicks per device type (mobile / desktop / tablet).

browsersobject[]
browsers[].browserstring
browsers[].clicksinteger
referrersobject[]
referrers[].referrerstring
referrers[].clicksinteger
osobject[]
os[].osstring
os[].clicksinteger

Errors

401 Missing or invalid API key.
403 Your plan does not include this feature, or a limit was reached.
404 The resource does not exist or is not yours.
429 Rate limit exceeded. Check X-RateLimit-Reset for when the window resets.

See Rate Limits & Errors for the error envelope and per-plan limits.

curl https://u2l.ai/api/v1/analytics/u.gy/my-link \
  -H "Authorization: Bearer u2l_live_your_api_key"
const response = await fetch("https://u2l.ai/api/v1/analytics/u.gy/my-link", {
  headers: {
    "Authorization": "Bearer u2l_live_your_api_key",
  },
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
    "https://u2l.ai/api/v1/analytics/u.gy/my-link",
    headers={"Authorization": "Bearer u2l_live_your_api_key"},
)

print(response.json())
package main

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

func main() {
	req, _ := http.NewRequest("GET", "https://u2l.ai/api/v1/analytics/u.gy/my-link", nil)
	req.Header.Set("Authorization", "Bearer u2l_live_your_api_key")
	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()

	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
{
  "totalClicks": 128,
  "clicksInRange": 96,
  "clicksToday": 8,
  "clicksThisWeek": 42,
  "timeRange": 30,
  "countries": [
    {
      "country": "US",
      "clicks": 54
    },
    {
      "country": "IN",
      "clicks": 31
    }
  ],
  "devices": {
    "mobile": 58,
    "desktop": 32,
    "tablet": 6
  },
  "browsers": [
    {
      "browser": "Chrome",
      "clicks": 61
    },
    {
      "browser": "Safari",
      "clicks": 24
    }
  ],
  "referrers": [
    {
      "referrer": "instagram.com",
      "clicks": 38
    },
    {
      "referrer": "direct",
      "clicks": 33
    }
  ],
  "os": [
    {
      "os": "Android",
      "clicks": 40
    },
    {
      "os": "iOS",
      "clicks": 25
    }
  ]
}