Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a href="https://dub.co">
<img alt="Dub is the open-source link attribution platform for modern marketing teams." src="https://github.com/user-attachments/assets/66749065-928d-4501-bae0-7e2b4c456f7d" />
<img alt="Dub Documentation Preview" src="./images/docs-preview.png" />
</a>

<h3 align="center">dubinc/docs</h3>
Expand All @@ -19,5 +19,5 @@ npm i -g mintlify
2. In the root of the repository, run the following command:

```
npm run dev
pnpm run dev
```
1 change: 1 addition & 0 deletions concepts/analytics/device.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Device data
description: "Retrieve analytics data grouped by device type, browser, and operating system."
og:title: "Dub Analytics API – Aggregating analytics by device"
---

Expand Down
1 change: 1 addition & 0 deletions concepts/analytics/location.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Location data
description: "Retrieve analytics data grouped by country, city, continent, and region."
og:title: "Dub Analytics API – Aggregating analytics by location"
---

Expand Down
1 change: 1 addition & 0 deletions concepts/analytics/referrers.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Referrers data
description: "Retrieve analytics data grouped by referrer domain and URL."
og:title: "Dub Analytics API – Aggregating analytics by referrers"
---

Expand Down
1 change: 1 addition & 0 deletions concepts/analytics/utm.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: UTM data
description: "Retrieve analytics data grouped by UTM source, medium, campaign, term, and content."
og:title: "Dub Analytics API – Aggregating analytics by UTM"
---

Expand Down
4 changes: 2 additions & 2 deletions conversions/leads/appwrite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ Next, configure Appwrite to track lead conversion events during the sign up proc
To learn more about how to track leads with Appwrite, check out the following example app:

<Card
title="Appwrite + Dub Next.js Example"
title="Appwrite + Dub Next.js example"
icon="github"
href="https://github.com/appwrite-community/appwrite-dub-next"
>
See how to track new user sign-ups with Appwrite and the Dub SDK.
See how to track new user sign-ups with Appwrite and the Dub SDK
</Card>

<LeadsOutro />
4 changes: 2 additions & 2 deletions conversions/leads/clerk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ Here's a quick summary of the steps:
To learn more about how to track leads with Clerk, check out the following example app:

<Card
title="Dub + Clerk Example App"
title="Dub + Clerk example app"
icon="github"
href="https://github.com/dubinc/examples/tree/main/conversions/clerk"
>
See how to track new user sign-ups with Clerk and the Dub SDK.
See how to track new user sign-ups with Clerk and the Dub SDK
</Card>

<LeadsOutro />
2 changes: 1 addition & 1 deletion conversions/leads/client-side.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Client-side tracking
og:title: Client-side lead tracking with Dub
description: Learn how to track lead conversion events with Dub using client-side tracking
description: Learn how to track lead conversion events with Dub using client-side tracking.
---

import LeadsIntro from "/snippets/leads-intro.mdx";
Expand Down
2 changes: 1 addition & 1 deletion conversions/leads/deferred.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Deferred lead tracking
description: Learn how to track a deferred lead conversion event with Dub
description: Learn how to track a deferred lead conversion event with Dub.
---

import LeadsIntro from "/snippets/leads-intro.mdx";
Expand Down
4 changes: 2 additions & 2 deletions conversions/leads/segment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ Next, configure [Segment Dub (Actions)](https://app.segment.com/goto-my-workspac
To learn more about how to track leads with Segment, check out the following example app:

<Card
title="Segment + Next.js App Router Example"
title="Segment + Next.js App Router example"
icon="github"
href="https://github.com/dubinc/examples/blob/main/conversions/segment/actions/track-lead.ts"
>
Next.js app using Segment to track new user sign-ups.
Next.js app using Segment to track new user sign-ups
</Card>

<LeadsOutro />
4 changes: 2 additions & 2 deletions conversions/leads/supabase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ export default async function handler(
To learn more about how to track leads with Supabase, check out the following example app:

<Card
title="Supabase + Next.js App Router Example"
title="Supabase + Next.js App Router example"
icon="github"
href="https://github.com/steven-tey/extrapolate/blob/main/app/api/auth/callback/route.ts"
>
Check out a real-world example of this in action – Extrapolate uses Supabase
Auth and Next.js App Router to track new user sign-ups.
Auth and Next.js App Router to track new user sign-ups
</Card>

<LeadsOutro />
53 changes: 53 additions & 0 deletions conversions/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DubClientInstallVerify from "/snippets/dub-client-install-verify.mdx";
import InstallServerSdksTrackConversions from "/snippets/install-server-sdks-track-conversions.mdx";
import ViewConversions from "/snippets/view-conversions.mdx";
import DubConversionTrackingDemoApps from "/snippets/dub-conversion-tracking-demo-apps.mdx";
import OpenAnalyticsSettings from "/snippets/open-analytics-settings.mdx";

<Note>
Conversion tracking requires a [Business plan](https://dub.co/pricing)
Expand All @@ -31,6 +32,10 @@ In this guide, we'll walk you through the steps to get started with conversion t

<EnableConversionTracking />

You'll also need to generate a publishable key and allowlist your site's domain to ensure client-side events are ingested by Dub. Navigate to your workspace's Analytics settings page to configure these options.

<OpenAnalyticsSettings />

## Step 2: Install the `@dub/analytics` client-side SDK

Next, you'll need to install the [@dub/analytics client-side SDK](/sdks/client-side/introduction).
Expand Down Expand Up @@ -59,6 +64,54 @@ Once you've enabled conversion tracking for your links, all your tracked convers

<ViewConversions />

## Integration options

Choose the integration method that best fits your stack to track leads and sales:

### Payment integrations

<CardGroup cols={2}>
<Card title="Stripe" icon="stripe-s" href="/conversions/sales/stripe">
**Best for:** SaaS and subscription revenue tracking. Automatically track purchases, subscriptions, and refunds
</Card>
<Card title="Shopify" icon="shopify" href="/conversions/sales/shopify">
**Best for:** E-commerce revenue tracking. Native app that automatically tracks all orders
</Card>
</CardGroup>

### Lead tracking

<CardGroup cols={2}>
<Card title="Google Tag Manager" icon="google" href="/conversions/leads/google-tag-manager">
**Best for:** Client-side lead event tracking. No-code setup for any platform
</Card>
<Card title="HubSpot" icon="hubspot" href="/conversions/leads/hubspot">
**Best for:** CRM lead tracking. Sync leads and deals directly to your CRM
</Card>
</CardGroup>

### Server-side SDKs

<CardGroup cols={3}>
<Card title="TypeScript" icon="js" href="/sdks/typescript">
TypeScript SDK for Node.js
</Card>
<Card title="Python" icon="python" href="/sdks/python">
Python SDK for server-side integration
</Card>
<Card title="Go" icon="golang" href="/sdks/go">
Go SDK for backend services
</Card>
<Card title="PHP" icon="php" href="/sdks/php">
PHP SDK for web applications
</Card>
<Card title="Ruby" icon="gem" href="/sdks/ruby">
Ruby SDK for Rails and more
</Card>
</CardGroup>

Dub also offers **Mobile SDKs** ([Swift](/sdks/client-side/swift), [React Native](/sdks/client-side/react-native)) for native app conversion tracking, and **Auth framework integrations** ([Clerk](/conversions/leads/clerk), [Better Auth](/conversions/leads/better-auth), [Auth0](/conversions/leads/auth0)) to automatically track signups as lead events.
Comment on lines +67 to +113
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix mobile SDK links to match the mobile SDK paths.

Line 113 links to \/sdks/client-side/swift`and`/sdks/client-side/react-native`, but the navigation uses the mobile SDK path prefix (e.g., `/sdks/client-side-mobile/...``). These links will likely 404.

🔧 Suggested fix
-Dub also offers **Mobile SDKs** ([Swift](/sdks/client-side/swift), [React Native](/sdks/client-side/react-native)) for native app conversion tracking, and **Auth framework integrations** ([Clerk](/conversions/leads/clerk), [Better Auth](/conversions/leads/better-auth), [Auth0](/conversions/leads/auth0)) to automatically track signups as lead events.
+Dub also offers **Mobile SDKs** ([Swift](/sdks/client-side-mobile/installation-guides/swift), [React Native](/sdks/client-side-mobile/installation-guides/react-native)) for native app conversion tracking, and **Auth framework integrations** ([Clerk](/conversions/leads/clerk), [Better Auth](/conversions/leads/better-auth), [Auth0](/conversions/leads/auth0)) to automatically track signups as lead events.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Integration options
Choose the integration method that best fits your stack to track leads and sales:
### Payment integrations
<CardGroup cols={2}>
<Card title="Stripe" icon="stripe-s" href="/conversions/sales/stripe">
**Best for:** SaaS and subscription revenue tracking. Automatically track purchases, subscriptions, and refunds
</Card>
<Card title="Shopify" icon="shopify" href="/conversions/sales/shopify">
**Best for:** E-commerce revenue tracking. Native app that automatically tracks all orders
</Card>
</CardGroup>
### Lead tracking
<CardGroup cols={2}>
<Card title="Google Tag Manager" icon="google" href="/conversions/leads/google-tag-manager">
**Best for:** Client-side lead event tracking. No-code setup for any platform
</Card>
<Card title="HubSpot" icon="hubspot" href="/conversions/leads/hubspot">
**Best for:** CRM lead tracking. Sync leads and deals directly to your CRM
</Card>
</CardGroup>
### Server-side SDKs
<CardGroup cols={3}>
<Card title="TypeScript" icon="js" href="/sdks/typescript">
TypeScript SDK for Node.js
</Card>
<Card title="Python" icon="python" href="/sdks/python">
Python SDK for server-side integration
</Card>
<Card title="Go" icon="golang" href="/sdks/go">
Go SDK for backend services
</Card>
<Card title="PHP" icon="php" href="/sdks/php">
PHP SDK for web applications
</Card>
<Card title="Ruby" icon="gem" href="/sdks/ruby">
Ruby SDK for Rails and more
</Card>
</CardGroup>
Dub also offers **Mobile SDKs** ([Swift](/sdks/client-side/swift), [React Native](/sdks/client-side/react-native)) for native app conversion tracking, and **Auth framework integrations** ([Clerk](/conversions/leads/clerk), [Better Auth](/conversions/leads/better-auth), [Auth0](/conversions/leads/auth0)) to automatically track signups as lead events.
## Integration options
Choose the integration method that best fits your stack to track leads and sales:
### Payment integrations
<CardGroup cols={2}>
<Card title="Stripe" icon="stripe-s" href="/conversions/sales/stripe">
**Best for:** SaaS and subscription revenue tracking. Automatically track purchases, subscriptions, and refunds
</Card>
<Card title="Shopify" icon="shopify" href="/conversions/sales/shopify">
**Best for:** E-commerce revenue tracking. Native app that automatically tracks all orders
</Card>
</CardGroup>
### Lead tracking
<CardGroup cols={2}>
<Card title="Google Tag Manager" icon="google" href="/conversions/leads/google-tag-manager">
**Best for:** Client-side lead event tracking. No-code setup for any platform
</Card>
<Card title="HubSpot" icon="hubspot" href="/conversions/leads/hubspot">
**Best for:** CRM lead tracking. Sync leads and deals directly to your CRM
</Card>
</CardGroup>
### Server-side SDKs
<CardGroup cols={3}>
<Card title="TypeScript" icon="js" href="/sdks/typescript">
TypeScript SDK for Node.js
</Card>
<Card title="Python" icon="python" href="/sdks/python">
Python SDK for server-side integration
</Card>
<Card title="Go" icon="golang" href="/sdks/go">
Go SDK for backend services
</Card>
<Card title="PHP" icon="php" href="/sdks/php">
PHP SDK for web applications
</Card>
<Card title="Ruby" icon="gem" href="/sdks/ruby">
Ruby SDK for Rails and more
</Card>
</CardGroup>
Dub also offers **Mobile SDKs** ([Swift](/sdks/client-side-mobile/installation-guides/swift), [React Native](/sdks/client-side-mobile/installation-guides/react-native)) for native app conversion tracking, and **Auth framework integrations** ([Clerk](/conversions/leads/clerk), [Better Auth](/conversions/leads/better-auth), [Auth0](/conversions/leads/auth0)) to automatically track signups as lead events.
🤖 Prompt for AI Agents
In `@conversions/quickstart.mdx` around lines 67 - 113, Update the two mobile SDK
links in the "Dub also offers Mobile SDKs" sentence so they use the mobile SDK
path prefix; replace "/sdks/client-side/swift" with
"/sdks/client-side-mobile/swift" and "/sdks/client-side/react-native" with
"/sdks/client-side-mobile/react-native" in the JSX/MDX block that renders the
mobile SDK links (the line containing "Dub also offers **Mobile SDKs**").


## Example Apps

<DubConversionTrackingDemoApps />
2 changes: 1 addition & 1 deletion conversions/sales/client-side.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Client-side tracking
og:title: Client-side sale tracking with Dub
description: Learn how to track sales conversion events with Dub on the client-side
description: Learn how to track sales conversion events with Dub on the client-side.
---

import SalesIntro from "/snippets/sales-intro.mdx";
Expand Down
2 changes: 1 addition & 1 deletion conversions/sales/direct.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Direct sale tracking
description: Learn how to track sales without a prior lead event using Dub
description: Learn how to track sales without a prior lead event using Dub.
---

import SalesIntro from "/snippets/sales-intro.mdx";
Expand Down
2 changes: 1 addition & 1 deletion conversions/sales/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Server-side tracking
sidebarTitle: Server-side tracking (recommended)
og:title: Server-side sale tracking with Dub
description: Learn how to track sales conversion events with Dub using server-side tracking
description: Learn how to track sales conversion events with Dub using server-side tracking.
---

import SalesIntro from "/snippets/sales-intro.mdx";
Expand Down
4 changes: 2 additions & 2 deletions conversions/sales/segment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ Next, configure [Segment Dub (Actions)](https://app.segment.com/goto-my-workspac
To learn more about how to track sales with Segment, check out the following example app:

<Card
title="Segment + Next.js App Router Example"
title="Segment + Next.js App Router example"
icon="github"
href="https://github.com/dubinc/examples/blob/main/conversions/segment/actions/track-sale.ts"
>
Next.js app using Segment to track sales.
Next.js app using Segment to track sales
</Card>

## View conversion results
Expand Down
4 changes: 2 additions & 2 deletions conversions/sales/stripe.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,11 @@ And that's it – you're all set! You can now sit back, relax, and watch your c

<CardGroup cols={2}>
<Card
title="Dub + Stripe Demo App"
title="Dub + Stripe demo app"
icon="github"
href="https://github.com/dubinc/examples/tree/main/conversions/stripe"
color="#333333"
>
See the full example on GitHub.
See the full example on GitHub
</Card>
</CardGroup>
66 changes: 48 additions & 18 deletions data-model.mdx
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
---
title: Data model
description: "A quick overview of how Dub is structured."
description: "Understanding the core data models in Dub."
---

Whether you are using Dub's [API](/api-reference/introduction) or not, this page is a quick way to understand how Dub works.
Understanding the core data models is key to using the Dub API and platform effectively. All data in Dub belongs to a Workspace, which acts as the top-level container for your organization.

Within Dub, all data belongs to a [**Workspace**](#workspace). Within a workspace, you have:
This page provides a conceptual overview of the primary entities you'll interact with and how they relate to each other, whether you're using the [Dub dashboard](https://app.dub.co) or the [Dub API](/api-reference/introduction).

- [Links](#links)
- [Analytics](#analytics)
- [Partners](#partners)
- [Customers](#customers)
- [Tags](#tags)
- [Domains](#domains)
## Core Entities

When interacting with Dub's API, you'll also need to create a [workspace API key](/api-reference/tokens) to authenticate your requests.
The following table defines the primary data models in Dub:

## Links
| Entity | Description |
| -------------- | ---------------------------------------------------------------------------------------------------------------- |
| **Workspace** | The top-level container for all your data. Invite team members, manage roles, and configure billing here. |
| **Program** | A partner program you create with configurable reward rules, commission structures, and enrolled partners. |
| **Partner** | A user who joined a program. They receive a unique referral link and can earn commissions on conversions. |
| **Link** | A short link that redirects to a destination URL. Can be standalone or associated with a partner for tracking. |
| **Analytics** | Aggregated data about link performance including clicks, geographic location, devices, referrers, and UTMs. |
| **Customer** | An end-user who clicked a partner's link and converted (e.g., signed up or made a purchase). |
| **Commission** | A record of a successful conversion attributed to a partner, with a status (pending, approved, paid) and amount. |
| **Domain** | A custom domain for branded short links. Improves brand recognition and click-through rates. |
| **Tag** | A label to organize, filter, and group links for easier management and analytics segmentation. |

Links are the bread and butter of Dub. You can shorten any URL to a Dub link, which you can then share with your audience. Links can be [created](/api-reference/endpoint/create-a-link), [updated](/api-reference/endpoint/update-a-link), and [deleted](/api-reference/endpoint/delete-a-link) via the [Dub API](/api-reference/introduction) or the [Dub dashboard](https://app.dub.co).
## Entity Relationships

## Domains
The diagram below illustrates how these entities relate to one another:

On Dub, you can [add custom domains](https://dub.co/help/article/how-to-add-custom-domain) to create branded short links for better brand recognition. You can also [set a primary domain](https://dub.co/help/article/how-to-set-primary-domain) for it to be used as the default domain for new links (both via the API and the dashboard).
<Frame>
<img
className="rounded-lg border border-gray-100"
src="/images/data-model.png"
alt="Dub Data Model - Entity Relationship Diagram"
/>
</Frame>

## Tags
## Key Relationships

Tags are a way to organize your links. You can [add tags to your links](https://dub.co/help/article/how-to-use-tags) to categorize them and make them easier to find. You can also [filter analytics by tags](https://dub.co/blog/introducing-tags#filtering-analytics-by-tags) to get a better understanding of how your campaigns are performing.
The relationships between entities follow a clear hierarchy:

## Workspace
1. **Workspace → Program**: A workspace can have multiple partner programs. Each program operates independently with its own reward rules and partners.

[Workspaces](https://dub.co/help/article/what-is-a-workspace) is the defacto way of organizing your links and working with your team on Dub. You can think of a Dub workspace like a workspace on Slack or Discord – it's a shared space where you can [invite your team members](https://dub.co/help/article/how-to-invite-teammates) to collaborate on links.
2. **Program → Partner**: Partners join a specific program. A single user could be a partner in multiple programs across different workspaces.

3. **Partner → Link**: When a partner joins a program, they receive a unique referral link. This link is used to track all referrals back to that partner.

4. **Link → Customer**: When a visitor clicks a partner's link and converts, they become a Customer. The customer is permanently associated with the referring link.

5. **Customer → Commission**: Each qualifying action by a customer (e.g., a purchase) generates a Commission record for the partner who referred them.

## Next Steps

Now that you understand the data model, you can:

<CardGroup cols={2}>
<Card title="Set up Dub Partners" icon="users" href="/partners/quickstart">
Create your first partner program and start tracking referrals
</Card>
<Card title="Explore the API" icon="code" href="/api-reference/introduction">
Learn how to interact with these entities programmatically
</Card>
</CardGroup>
Loading