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
The total number of events over the specified time period.
Example response:
timeseries
The number of events over a given time interval, broken down by time periods.
Example response:
top_links
The top links by event count, including link metadata.
Example response:
countries
The top countries by event count, using ISO 3166-1 alpha-2 country codes.
Example response:
cities
The top cities by event count, including city names and ISO 3166-1 alpha-2 country codes.
Example response:
regions
The top regions by event count, including region codes and ISO 3166-1 alpha-2 country codes.
Example response:
continents
The top continents by event count, using 2-letter ISO continent codes.
Example response:
devices
The top devices by event count, including device names.
Example response:
browsers
The top browsers by event count, including browser names.
Example response:
os
The top operating systems by event count, including OS names.
Example response:
referrers
The top referrers by event count, including referrer names.
Example response:
referer_urls
The top referrer URLs by event count, including full URLs.
Example response:
utm_sources
The top UTM sources by event count.
Example response:
utm_mediums
The top UTM mediums by event count.
Example response:
utm_campaigns
The top UTM campaigns by event count.
Example response:
utm_terms
The top UTM terms by event count.
Example response:
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:
And here's another real-world example of a custom analytics dashboard built with the Analytics API:
