Skip to content

Analytics API

API endpoints for accessing analytics data

Access detailed analytics data for your links and profiles.

Get analytics data for a specific link.

GET /v1/links/:id/stats

Query Parameters

ParameterTypeDefaultDescription
startstring30 days agoStart date (ISO 8601)
endstringnowEnd date (ISO 8601)
intervalstringdayGrouping interval (hour, day, week, month)

Example Request

curl -X GET "https://api.linked.is/v1/links/clx1234567890/stats?start=2024-01-01&end=2024-01-31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
<script setup lang="ts">
const getLinkStats = async () => {
  const response = await fetch(
    "https://api.linked.is/v1/links/clx1234567890/stats?start=2024-01-01&end=2024-01-31",
    {
      headers: {
        Authorization: "Bearer YOUR_API_TOKEN",
      },
    },
  );

  const data = await response.json();
  console.log(data);
  return data;
};
</script>

<template>
  <div>
    <button @click="getLinkStats">Get Link Stats</button>
  </div>
</template>

Example Response

<script setup lang="ts">
const linkStatsResponse = {
  success: true,
  data: {
    totalClicks: 1250,
    uniqueVisitors: 890,
    clicksOverTime: [
      { date: "2024-01-01", clicks: 45 },
      { date: "2024-01-02", clicks: 52 },
      { date: "2024-01-03", clicks: 38 }
    ],
    countries: [
      { country: "United States", code: "US", clicks: 450 },
      { country: "United Kingdom", code: "GB", clicks: 220 },
      { country: "Germany", code: "DE", clicks: 180 }
    ],
    cities: [
      { city: "New York", country: "US", clicks: 120 },
      { city: "London", country: "GB", clicks: 95 }
    ],
    devices: [
      { device: "mobile", clicks: 680 },
      { device: "desktop", clicks: 520 },
      { device: "tablet", clicks: 50 }
    ],
    browsers: [
      { browser: "Chrome", clicks: 650 },
      { browser: "Safari", clicks: 320 },
      { browser: "Firefox", clicks: 180 }
    ],
    operatingSystems: [
      { os: "iOS", clicks: 420 },
      { os: "Windows", clicks: 380 },
      { os: "Android", clicks: 260 },
      { os: "macOS", clicks: 140 }
    ],
    referrers: [
      { referrer: "twitter.com", clicks: 320 },
      { referrer: "instagram.com", clicks: 280 },
      { referrer: "direct", clicks: 450 }
    ]
  }
};
</script>

<template>
  <pre>{{ JSON.stringify(linkStatsResponse, null, 2) }}</pre>
</template>

Get Profile Stats

Get analytics data for a bio profile.

GET /v1/profiles/:id/stats

Query Parameters

ParameterTypeDefaultDescription
startstring30 days agoStart date (ISO 8601)
endstringnowEnd date (ISO 8601)

Example Request

curl -X GET "https://api.linked.is/v1/profiles/prof_123456/stats?start=2024-01-01&end=2024-01-31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
<script setup lang="ts">
const getProfileStats = async () => {
  const response = await fetch(
    "https://api.linked.is/v1/profiles/prof_123456/stats?start=2024-01-01&end=2024-01-31",
    {
      headers: {
        Authorization: "Bearer YOUR_API_TOKEN",
      },
    },
  );

  const data = await response.json();
  console.log(data);
  return data;
};
</script>

<template>
  <div>
    <button @click="getProfileStats">Get Profile Stats</button>
  </div>
</template>

Example Response

<script setup lang="ts">
const profileStatsResponse = {
  success: true,
  data: {
    totalViews: 5420,
    uniqueVisitors: 3200,
    viewsOverTime: [
      { date: "2024-01-01", views: 180 },
      { date: "2024-01-02", views: 195 }
    ],
    countries: [
      { country: "United States", code: "US", views: 1800 }
    ],
    devices: [
      { device: "mobile", views: 3200 },
      { device: "desktop", views: 2000 }
    ],
    blockClicks: [
      { blockId: "block_1", label: "My Website", clicks: 450 },
      { blockId: "block_2", label: "Twitter", clicks: 320 }
    ],
    referrers: [
      { referrer: "instagram.com", views: 1200 },
      { referrer: "twitter.com", views: 800 }
    ],
    hourlyStats: [
      { hour: 0, views: 120 },
      { hour: 1, views: 85 },
      { hour: 12, views: 420 },
      { hour: 18, views: 380 }
    ]
  }
};
</script>

<template>
  <pre>{{ JSON.stringify(profileStatsResponse, null, 2) }}</pre>
</template>

Get Account Overview

Get aggregated analytics for your entire account.

GET /v1/analytics/overview

Example Response

<script setup lang="ts">
const accountOverviewResponse = {
  success: true,
  data: {
    totalLinks: 45,
    totalClicks: 12500,
    totalProfiles: 3,
    totalProfileViews: 8200,
    topLinks: [
      {
        id: "clx1234567890",
        slug: "my-link",
        clicks: 2500
      }
    ],
    topProfiles: [
      {
        id: "prof_123456",
        slug: "johndoe",
        views: 5420
      }
    ],
    clicksLast30Days: 4200,
    viewsLast30Days: 2800
  }
};
</script>

<template>
  <pre>{{ JSON.stringify(accountOverviewResponse, null, 2) }}</pre>
</template>

Real-time Stats

Get real-time visitor data (last 5 minutes).

GET /v1/analytics/realtime

Example Response

<script setup lang="ts">
const realtimeStatsResponse = {
  success: true,
  data: {
    activeVisitors: 12,
    recentClicks: [
      {
        linkId: "clx1234567890",
        timestamp: "2024-01-15T14:32:15Z",
        country: "US",
        device: "mobile"
      }
    ],
    recentViews: [
      {
        profileId: "prof_123456",
        timestamp: "2024-01-15T14:31:45Z",
        country: "GB",
        device: "desktop"
      }
    ]
  }
};
</script>

<template>
  <pre>{{ JSON.stringify(realtimeStatsResponse, null, 2) }}</pre>
</template>

Export Data

Export analytics data in CSV format.

GET /v1/analytics/export

Query Parameters

ParameterTypeRequiredDescription
typestringYesExport type (links, profiles, clicks)
startstringYesStart date
endstringYesEnd date
formatstringNoExport format (csv, json)

Example Request

curl -X GET "https://api.linked.is/v1/analytics/export?type=clicks&start=2024-01-01&end=2024-01-31&format=csv" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -o clicks_export.csv
<script setup lang="ts">
const exportData = async () => {
  const response = await fetch(
    "https://api.linked.is/v1/analytics/export?type=clicks&start=2024-01-01&end=2024-01-31&format=csv",
    {
      headers: {
        Authorization: "Bearer YOUR_API_TOKEN",
      },
    },
  );

  // Handle CSV response
  const blob = await response.blob();
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "clicks_export.csv";
  a.click();
  window.URL.revokeObjectURL(url);
};
</script>

<template>
  <div>
    <button @click="exportData">Export Data</button>
  </div>
</template>

Webhooks (Coming Soon)

Subscribe to real-time analytics events via webhooks.

POST /v1/webhooks

Available events:

  • link.clicked - When a link is clicked
  • profile.viewed - When a profile is viewed
  • link.created - When a new link is created