Analytics endpoints require a Pro plan subscription or higher.

UTM data allows you to analyze the effectiveness of your marketing campaigns by tracking the source, medium, campaign, term, and content parameters.

UTM source analytics

The top UTM sources by 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: "utm_sources",
  linkId: "clux0rgak00011...",
  interval: "30d",
});

UTM medium analytics

The top UTM mediums by 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: "utm_mediums",
  linkId: "clux0rgak00011...",
  interval: "30d",
});

UTM campaign analytics

The top UTM campaigns by 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: "utm_campaigns",
  linkId: "clux0rgak00011...",
  interval: "30d",
});

UTM term analytics

The top UTM terms by 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: "utm_terms",
  linkId: "clux0rgak00011...",
  interval: "30d",
});

UTM content analytics

The top UTM contents by 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: "utm_contents",
  linkId: "clux0rgak00011...",
  interval: "30d",
});