Skip to Content
📝

Analytics endpoints require a Pro plan  subscription or higher.

Dub’s Analytics API allows you to build real-time analytics dashboards for your links that lives directly inside your application.

Fundamentals

At a high level, Dub’s Analytics API allows you to retrieve data about your links by event type and group by different dimensions.

Dub’s Analytics API supports the following event types:

  • clicks – the number of clicks on a link
  • leads – the number of leads generated from a link
  • sales – the number of sales generated from a link

Each of these events can be aggregated in different ways by using the groupBy parameter:

Example queries

Here are some examples of how to retrieve data using Dub’s Analytics API:

Total event count

import { Dub } from "dub"; export const dub = new Dub({ token: process.env.DUB_API_KEY, }); const result = await dub.analytics.retrieve({ event: "clicks", groupBy: "count", linkId: "clux0rgak00011...", interval: "30d", });

Timeseries data

import { Dub } from "dub"; export const dub = new Dub({ token: process.env.DUB_API_KEY, }); const result = await dub.analytics.retrieve({ event: "clicks", groupBy: "timeseries", linkId: "clux0rgak00011...", interval: "30d", });
import { Dub } from "dub"; export const dub = new Dub({ token: process.env.DUB_API_KEY, }); const result = await dub.analytics.retrieve({ event: "clicks", groupBy: "top_links", linkId: "clux0rgak00011...", interval: "30d", });

Example apps

With Dub’s Analytics API, you can build user-facing analytics dashboards with the real-time click and conversion data for your links.

Here are some open-source examples of how you can use the Analytics API to build your own custom analytics dashboards:

github

OSS Gallery

Programmatically shorten links and fetch real-time click analytics with Dub

github

Cap.so

How Cap.so fetches real-time click analytics for their recording links

And here’s another real-world example  of a custom analytics dashboard built with the Analytics API:

Assembly link analytics