Skip to main content

Endpoint

https://api.dub.co/events

Authentication

This endpoint requires authentication using a Bearer token.
Authorization
string
required
Bearer token for authentication
This endpoint requires a Business plan or higher.

Query Parameters

Event Configuration

event
enum
default:"clicks"
required
The type of event to retrieve analytics for. Defaults to ‘clicks’.Options: clicks, leads, sales

Pagination

page
number
default:1
The page number for pagination. Defaults to 1.
limit
number
default:50
The number of events to return per page. Max 1000 items per page.

Sorting

sortBy
enum
default:"timestamp"
The field to sort the events by. The default is timestamp.Options: timestamp
sortOrder
enum
default:"desc"
The sort order. The default is desc.Options: asc, desc
domain
string
The domain to filter analytics for. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with -).
key
string
The slug of the short link to retrieve analytics for. Must be used along with the corresponding domain of the short link.
The unique ID of the link to retrieve analytics for. Supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with -).
externalId
string
The ID of the link in your database. Must be prefixed with ‘ext_’ when passed as a query parameter.

Time Range

interval
enum
The interval to retrieve analytics for. If undefined, defaults to 24h.Options: 1h, 24h, 7d, 30d, 90d, ytd, 1y, all, all_unfiltered
start
string
The start date and time when to retrieve analytics from. If set, takes precedence over interval. Format: ISO 8601 date string.
end
string
The end date and time when to retrieve analytics from. If not provided, defaults to the current date. If set along with start, takes precedence over interval.
timezone
string
default:"UTC"
The IANA time zone code for aligning timeseries granularity (e.g. America/New_York). Defaults to UTC.

Filtering

tenantId
string
The ID of the tenant that created the link inside your system. Supports advanced filtering.
tagId
string
The tag ID to retrieve analytics for. Supports advanced filtering.
folderId
string
The folder ID to retrieve analytics for. Supports advanced filtering. If not provided, return analytics for all links.
groupId
string
The group ID to retrieve analytics for. Supports advanced filtering.
partnerId
string
The ID of the partner to retrieve analytics for. Supports advanced filtering.
customerId
string
The ID of the customer to retrieve analytics for.

Geographic Filters

country
string
The country to retrieve analytics for. Must be passed as a 2-letter ISO 3166-1 country code. Supports advanced filtering.
city
string
The city to retrieve analytics for. Supports advanced filtering.
region
string
The ISO 3166-2 region code to retrieve analytics for. Supports advanced filtering.
continent
string
The continent to retrieve analytics for. Valid values: AF, AN, AS, EU, NA, OC, SA. Supports advanced filtering.

Device & Browser Filters

device
string
The device to retrieve analytics for. Supports advanced filtering.
browser
string
The browser to retrieve analytics for. Supports advanced filtering.
os
string
The OS to retrieve analytics for. Supports advanced filtering.

Traffic Source Filters

trigger
string
The trigger to retrieve analytics for. Valid values: qr, link, pageview. Supports advanced filtering. If undefined, returns all trigger types.
referer
string
The referer hostname to retrieve analytics for. Supports advanced filtering.
refererUrl
string
The full referer URL to retrieve analytics for. Supports advanced filtering.

UTM Parameters

utm_source
string
The UTM source to retrieve analytics for. Supports advanced filtering.
utm_medium
string
The UTM medium to retrieve analytics for. Supports advanced filtering.
utm_campaign
string
The UTM campaign to retrieve analytics for. Supports advanced filtering.
utm_term
string
The UTM term to retrieve analytics for. Supports advanced filtering.
utm_content
string
The UTM content to retrieve analytics for. Supports advanced filtering.

Other Filters

url
string
The destination URL to retrieve analytics for. Supports advanced filtering.
root
boolean
Filter for root domains. If true, filter for domains only. If false, filter for links only. If undefined, return both.
saleType
enum
Filter sales by type: ‘new’ for first-time purchases, ‘recurring’ for repeat purchases. If undefined, returns both.Options: new, recurring
query
string
Search the events by a custom metadata value. Only available for lead and sale events. Max 10,000 characters.

Response

Returns an array of event objects. The structure of each event depends on the event type:

Click Event

event
string
The event type: click
timestamp
string
The timestamp of the event in ISO 8601 format
click
object
The click event details
The link details

Lead Event

event
string
The event type: lead
timestamp
string
The timestamp of the event in ISO 8601 format
eventId
string
The unique ID of the lead event
eventName
string
The name of the lead event (e.g., “Sign up”)
metadata
object
Additional metadata stored with the lead event
click
object
The click event details (same structure as Click Event above)
The link details (same structure as Click Event above)
customer
object
The customer details

Sale Event

event
string
The event type: sale
timestamp
string
The timestamp of the event in ISO 8601 format
eventId
string
The unique ID of the sale event
eventName
string
The name of the sale event (e.g., “Invoice paid”)
sale
object
The sale details
metadata
object
Additional metadata stored with the sale event
click
object
The click event details (same structure as Click Event above)
The link details (same structure as Click Event above)
customer
object
The customer details (same structure as Lead Event above)

Examples

curl -X GET "https://api.dub.co/events?event=clicks&limit=100&sortOrder=desc" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response Examples

[
  {
    "event": "click",
    "timestamp": "2024-01-15T14:32:10.000Z",
    "click": {
      "id": "clk_abc123",
      "url": "https://github.com/dubinc/dub",
      "country": "US",
      "city": "New York",
      "region": "NY",
      "continent": "NA",
      "device": "Desktop",
      "browser": "Chrome",
      "os": "Mac",
      "referer": "google.com",
      "refererUrl": "https://google.com/search?q=dub",
      "qr": false,
      "ip": "192.168.1.1"
    },
    "link": {
      "id": "clux0rgak00011...",
      "domain": "dub.co",
      "key": "github",
      "url": "https://github.com/dubinc/dub",
      "externalId": "123456",
      "programId": null,
      "tenantId": null
    }
  }
]

Build docs developers (and LLMs) love