Dub.co

Create branded short links, manage UTM parameters, and track marketing campaign performance with Dub.co.

Dub.co is Nebutra's link management and marketing analytics layer. It handles everything that happens before a user reaches the product: branded short URLs, UTM tracking, and click-through analytics.

What Dub.co Provides

  • Branded short linkslinks.nebutra.com/welcome, links.nebutra.com/upgrade-pro
  • UTM management — source, medium, campaign, term, and content parameters on every link
  • Click analytics — clicks, unique visitors, referrers, devices, and countries per link
  • Campaign grouping — group links by campaign for aggregate reporting
  • QR codes — auto-generated for each short link

Setup

Sign up at dub.co and create a workspace for your Nebutra project.

In the Dub.co workspace settings, add your branded link domain (e.g. links.nebutra.com). Follow Dub.co's DNS instructions to configure the CNAME record.

Go to Workspace SettingsAPI KeysCreate API Key. Copy the key — it starts with dub_.

Add the key to your server-side environment (never expose it client-side):

DUB_API_KEY=dub_xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Run the following snippet in a local script or the API gateway REPL to confirm authentication:

import { dub } from "@nebutra/analytics";

const workspaces = await dub.workspaces.list();
console.log(workspaces);

You should see your workspace returned without errors.

Use the dub client from @nebutra/analytics to create links programmatically:

import { dub } from "@nebutra/analytics";

// Welcome email link
const welcomeLink = await dub.links.create({
  url: "https://app.nebutra.com/dashboard",
  domain: "links.nebutra.com",
  slug: "welcome",
  utm_source: "email",
  utm_medium: "transactional",
  utm_campaign: "onboarding",
});

// Upgrade nudge in-app banner
const upgradeLink = await dub.links.create({
  url: "https://app.nebutra.com/settings/billing",
  domain: "links.nebutra.com",
  utm_source: "app",
  utm_medium: "banner",
  utm_campaign: "upgrade-pro",
  utm_content: "quota-warning-banner",
});

console.log(welcomeLink.shortLink); // → https://links.nebutra.com/welcome

UTM Parameter Conventions

Nebutra uses a consistent UTM taxonomy across all campaigns. Adhere to these conventions so PostHog attribution stays clean:

ParameterValuesExamples
utm_sourceOrigin of trafficemail, app, twitter, linkedin, google
utm_mediumChannel typetransactional, newsletter, cpc, banner, social
utm_campaignCampaign slug (kebab-case)onboarding, upgrade-pro, launch-v2
utm_contentSpecific element (optional)cta-button, quota-warning-banner, hero-headline
utm_termPaid search keyword (optional)saas-analytics-tool

Always use lowercase kebab-case for all UTM values. Mixed case causes duplicate attribution entries in PostHog.

Transactional Emails

Every transactional email CTA should use a tracked link:

import { dub } from "@nebutra/analytics";

async function sendWelcomeEmail(user: User) {
  const ctaLink = await dub.links.create({
    url: `https://app.nebutra.com/onboarding?userId=${user.id}`,
    domain: "links.nebutra.com",
    utm_source: "email",
    utm_medium: "transactional",
    utm_campaign: "onboarding",
    utm_content: "welcome-email-cta",
  });

  await sendEmail({
    to: user.email,
    subject: "Welcome to Nebutra",
    cta: { label: "Get started", href: ctaLink.shortLink },
  });
}
import { dub } from "@nebutra/analytics";

async function generateReferralLink(userId: string, orgSlug: string) {
  return dub.links.create({
    url: `https://nebutra.com/?ref=${orgSlug}`,
    domain: "links.nebutra.com",
    utm_source: "referral",
    utm_medium: "in-app",
    utm_campaign: "user-referral",
    utm_content: userId,
    // tag for grouping in Dub.co dashboard
    tags: ["referral", `user-${userId}`],
  });
}

Marketing Campaigns

For paid campaigns, create links in bulk via the Dub.co dashboard or the API and assign them to a campaign tag:

const variants = ["headline-a", "headline-b", "headline-c"];

const links = await Promise.all(
  variants.map((variant) =>
    dub.links.create({
      url: "https://nebutra.com/landing/paid",
      domain: "links.nebutra.com",
      utm_source: "google",
      utm_medium: "cpc",
      utm_campaign: "q1-acquisition",
      utm_content: variant,
      tags: ["paid", "q1-acquisition"],
    })
  )
);

Viewing Analytics

Link analytics are available in the Dub.co dashboard at app.dub.co:

  • Link analytics — clicks over time, referrers, countries, devices per link
  • Campaign analytics — aggregate metrics per tag/campaign
  • Top links — ranked by click volume

Dub.co link analytics are currently available via the Dub.co dashboard at app.dub.co. In-app surfacing under /admin/analytics is on the roadmap. Until then, use the retrieveLinkStats() helper (see below) to embed metrics programmatically into your own admin views.

import { dub } from "@nebutra/analytics";

const stats = await dub.analytics.retrieve({
  linkId: welcomeLink.id,
  interval: "30d",
  groupBy: "referrer",
});

// stats.clicks → total clicks
// stats.groupedData → breakdown by referrer

How is this guide?

Edit on GitHub

Last updated on

On this page