Skip to main content
Analytics endpoints require a Pro plan subscription or higher. Partner-related analytics also require an active Dub Partners program.
Partner data allows you to analyze how your partners, partner groups, and partner tags are driving clicks, leads, and sales across your program.

Partner analytics

The top partners by event count, including partner names and IDs.
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_partners",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});
You can also filter analytics for a specific partner (or set of partners) by passing the partnerId parameter. It supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with -).
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_links",
  partnerId: "pn_123",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});

Partner group analytics

The top partner groups by event count, including group names and IDs.
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_groups",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});
You can also filter analytics by one or more partner groups by passing the groupId parameter. It supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with -).
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_partners",
  groupId: "grp_123",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});

Partner tag analytics

The top partner tags by event count, including tag names and IDs.
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_partner_tags",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});
You can also filter analytics by one or more partner tags by passing the partnerTagId parameter. It supports advanced filtering: single value, multiple values (comma-separated), or exclusion (prefix with -).
import { Dub } from "dub";

export const dub = new Dub({
  token: process.env.DUB_API_KEY,
});

const result = await dub.analytics.retrieve({
  event: "sales",
  groupBy: "top_partners",
  partnerTagId: "ptag_123",
  interval: "30d",
  // saleType: "new" // Optional: filter by new or recurring sales
});