# Server-side tracking

> Learn how to track conversion events with Dub using server-side tracking.

import EnableConversionTracking from "/snippets/enable-conversion-tracking.mdx";
import DubClientInstall from "/snippets/dub-client-install.mdx";
import DubClientInstallVerify from "/snippets/dub-client-install-verify.mdx";
import AuthProviders from "/snippets/auth-providers.mdx";
import ViewConversions from "/snippets/view-conversions.mdx";
import DubConversionTrackingDemoApps from "/snippets/dub-conversion-tracking-demo-apps.mdx";

<Tip>
  This feature is only available on [Business plans and
  above](https://dub.co/pricing/partners).
</Tip>

Dub's powerful [attribution platform](/docs/concepts/attribution) lets you understand how well your links are translating to actual users and revenue dollars.

<Frame>
  <img
    src="https://assets.dub.co/blog/introducing-dub-conversions.webp"
    alt="Conversion analytics"
  />
</Frame>

In this guide, we'll learn how to track conversion events with Dub using server-side tracking.

<Note>

The recommended way to track conversions on Dub is using server-side tracking, which is more reliable than [client-side tracking](/docs/quickstart/client).

</Note>

## Step 1: Enable conversion tracking for your links

<EnableConversionTracking />

## Step 2: Install the Dub Analytics script

Next, you'll need to install the [Dub Analytics script](/docs/sdks/client-side/introduction).

This script detects the `dub_id` query parameter and storing it as a first-party cookie, which will be used to attribute subsequent conversion events to the original link.

<Frame>
  <img
    src="https://assets.dub.co/help/conversion-click-event.png"
    alt="A diagram showing how click events are tracked in the conversion funnel"
  />
</Frame>

<DubClientInstall />

<DubClientInstallVerify />

## Step 3: Install the Dub server-side SDK

Depending on which framework you're using, you can use our [native SDKs](/docs/sdks/overview) to track conversion events:

<CardGroup>
  <Card title="TypeScript" icon="npm" href="/docs/sdks/typescript" horizontal>
    TypeScript library for the Dub API
  </Card>
  <Card
    title="Go"
    icon="golang"
    href="/docs/sdks/go"
    iconType="brands"
    horizontal
  >
    Go library for the Dub API
  </Card>
  <Card title="Python" icon="python" href="/docs/sdks/python" horizontal>
    Python library for the Dub API
  </Card>
  <Card title="Ruby" icon="gem" href="/docs/sdks/ruby" horizontal>
    Ruby library for the Dub API
  </Card>
  <Card title="PHP" icon="php" href="/docs/sdks/php" horizontal>
    PHP library for the Dub API
  </Card>
</CardGroup>

If you're using a framework that isn't listed, you can use the Dub REST API to track events on the server-side:

- [`POST /track/lead`](/docs/api-reference/track/lead)
- [`POST /track/sale`](/docs/api-reference/track/sale)

## Step 4: Track conversion events

Now comes the fun part – tracking conversion events.

### Tracking lead events

The first event you'll want to track is a `lead` event. This happens when a user performs an action that indicates interest in your product or service. This could be anything from:

- Signing up for an account
- Adding a product to cart
- Joining a mailing list

<Frame>
  <img
    src="https://assets.dub.co/help/conversion-lead-event.png"
    alt="A diagram showing how lead events are tracked in the conversion funnel"
  />
</Frame>

Our most common lead event is `Sign Up`, which happens when a user signs up for an account. Depending on which authentication framework you're using, here are a few examples of how to send `Sign Up` lead events:

<AuthProviders />

The lead event will serve as the source of truth for the customer's identity and which link they came from. This means that all subsequent actions performed by the customer (e.g. upgrading their plan, purchasing a product) will automatically be attributed to the original link.

### Tracking sale events

The second event you'll want to send is a `sale` event. This happens when a user purchases your product or service. This could be anything from:

- Subscribing to a paid plan
- Usage expansion (upgrading from one plan to another)
- Purchasing a product

<Frame>
  <img
    src="https://assets.dub.co/help/conversion-sale-event.png"
    alt="A diagram showing how sale events are tracked in the conversion funnel"
  />
</Frame>

Depending on which payment processor you're using, we offer native integrations for the following:

<CardGroup cols={2}>
  <Card
    title="Stripe"
    icon="stripe"
    href="https://dub.co/docs/integrations/stripe"
    horizontal
  />
  <Card
    title="Shopify"
    icon="shopify"
    href="https://dub.co/docs/integrations/stripe"
    horizontal
  />
</CardGroup>

Alternatively, you can also send sale events manually using [our SDKs](/docs/sdks/overview) or the [`POST /track/sale` API endpoint](/docs/api-reference/track/sale).

<Tip>
  Looking to track sales without a prior lead event? Check out our [direct sale
  tracking guide](/docs/conversions/sales/direct).

Looking to track refunds? Check out our [refunds tracking guide](/docs/conversions/sales/refunds).

</Tip>

## Step 5: View your conversions

Once you've enabled conversion tracking for your links, all your tracked conversions will show up on your [Analytics dashboard](https://app.dub.co/analytics). We provide 3 different views to help you understand your conversions:

<ViewConversions />

## Example Apps

<DubConversionTrackingDemoApps />
