Introduction
Learn how to use Dub’s Analytics API to build real-time analytics dashboards for your links.
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 linkleads
– the number of leads generated from a linksales
– the number of sales generated from a link
Each of these events can be aggregated in different ways by using the groupBy
parameter:
count
count
The total number of events over the specified time period.
Example response:
timeseries
timeseries
The number of events over a given time interval, broken down by time periods.
Example response:
top_links
top_links
The top links by event count, including link metadata.
Example response:
countries
countries
The top countries by event count, using ISO 3166-1 alpha-2 country codes.
Example response:
cities
cities
The top cities by event count, including city names and ISO 3166-1 alpha-2 country codes.
Example response:
regions
regions
The top regions by event count, including region codes and ISO 3166-1 alpha-2 country codes.
Example response:
continents
continents
The top continents by event count, using 2-letter ISO continent codes.
Example response:
devices
devices
The top devices by event count, including device names.
Example response:
browsers
browsers
The top browsers by event count, including browser names.
Example response:
os
os
The top operating systems by event count, including OS names.
Example response:
referrers
referrers
The top referrers by event count, including referrer names.
Example response:
referer_urls
referer_urls
The top referrer URLs by event count, including full URLs.
Example response:
utm_sources
utm_sources
The top UTM sources by event count.
Example response:
utm_mediums
utm_mediums
The top UTM mediums by event count.
Example response:
utm_campaigns
utm_campaigns
The top UTM campaigns by event count.
Example response:
utm_terms
utm_terms
The top UTM terms by event count.
Example response:
utm_contents
utm_contents
The top UTM contents by event count.
Example response:
Example queries
Here are some examples of how to retrieve data using Dub’s Analytics API:
Total event count
Timeseries data
Top links by event
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:
OSS Gallery
Programmatically shorten links and fetch real-time click analytics with Dub
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: