Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
10 changes: 6 additions & 4 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@
"pages": [
"help/article/program-bounties",
"help/article/email-campaigns",
"help/article/messaging-partners"
"help/article/messaging-partners",
"help/article/submitted-leads"
]
},
{
Expand Down Expand Up @@ -430,16 +431,17 @@
"docs/sdks/client-side/installation-guides/shopify"
]
},
"docs/sdks/client-side/variants",
{
"group": "Features",
"pages": [
"docs/sdks/client-side/features/click-tracking",
"docs/sdks/client-side/features/conversion-tracking",
"docs/sdks/client-side/features/cross-domain-tracking",
"docs/sdks/client-side/features/reverse-proxy-support"
"docs/sdks/client-side/features/reverse-proxy-support",
"docs/sdks/client-side/features/identity-tracking"
]
},
"docs/sdks/client-side/variants"
}
]
},
{
Expand Down
7 changes: 3 additions & 4 deletions docs/sdks/client-side/features/click-tracking.mdx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
---
title: Client-side click tracking
description: Track clicks on the client-side using query parameters
---

import ClickIdSpoofingPreventionTip from "/snippets/click-id-spoofing-prevention-tip.mdx";
import DubAnalyticsParams from "/snippets/dub-analytics-params-react.mdx";
import VerifyTrackClick from "/snippets/verify-track-click.mdx";
import FetchPartnerDiscountData from "/snippets/fetch-partner-discount-data.mdx";

With the [Dub Analytics script](/docs/sdks/client-side/introduction), you can track clicks on the client-side using query parameters (e.g. `?via=john`, `?ref=jane`).
One of the core features of the [Dub Analytics script](/docs/sdks/client-side/introduction) is the ability to track clicks on the client-side using query parameters (e.g. `?via=john`, `?ref=jane`).

A few use cases include:
There are several use cases for this feature:

- You're using [Dub Partners](/help/article/dub-partners) with [dual-sided incentives](/help/article/dual-sided-incentives) and want to display a banner that says: _"John referred you to Acme and gave you 25% off"_
- You are migrating from an existing affiliate management platform (e.g. [Rewardful](/help/article/migrating-from-rewardful)) that uses query parameters to track conversions.
- You are running an ad on a platform like Google/Reddit that requires you to use your main site domain for the URL (no short links allowed) – so instead of using a short link, you can use a query parameter to track clicks.
- You have dynamically generated referral pages (e.g. [Tesla](https://www.tesla.com/referral/peeroke520149)) and want to track clicks [using a `trackClick()` function](#manually-tracking-clicks-with-the-trackclick-function) inside your application code.
- You have dynamically generated referral pages (e.g. Tesla's [user referral pages](https://www.tesla.com/referral/peeroke520149)) and want to track clicks [using a `trackClick()` function](#manually-tracking-clicks-with-the-trackclick-function) inside your application code.

<ClickIdSpoofingPreventionTip />

Expand Down Expand Up @@ -138,7 +137,7 @@
- Dynamic user-generated content/webpages:
- Dub's public analytics dashboards (e.g. [app.dub.co/share/:slug](https://app.dub.co/share/dash_6NSA6vNm017MZwfzt8SubNSZ))
- v0 template pages (e.g. [v0.app/templates/:slug](https://v0.app/templates/evasion-e-commerce-template-annqMtFCROP))
- Tella's video pages (e.g. [tella.tv/video/:slug](https://www.tella.tv/video/cluvcfcfi00tw0fjrgizr4pw2))

Check warning on line 140 in docs/sdks/client-side/features/click-tracking.mdx

View check run for this annotation

Mintlify / Mintlify Validation (dub) - vale-spellcheck

Vale.Spelling

Did you really mean 'Tella's'?

The `trackClick()` function allows you to manually trigger click events from your application code. This is useful when you want to track clicks that happen programmatically.

Expand Down
32 changes: 5 additions & 27 deletions docs/sdks/client-side/features/conversion-tracking.mdx
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
---
title: Client-side conversion tracking
sidebarTitle: Conversion tracking
description: Learn how to use the Dub Analytics script to track conversion events on the client-side
---

import ClientSideTrackingWarning from "/snippets/client-side-tracking-warning.mdx";
import EnableConversionTracking from "/snippets/enable-conversion-tracking.mdx";
import ClientSideTrackingInstall from "/snippets/client-side-tracking-install.mdx";
import ClientSideLeadTracking from "/snippets/client-side-lead-tracking.mdx";
import ClientSideSaleTracking from "/snippets/client-side-sale-tracking.mdx";

Dub Analytics is a client-side script for [tracking conversion events](/docs/concepts/attribution) with Dub.
Another feature of the Dub Analytics script is the ability to [track conversion events on the client-side](/docs/quickstart/client).

By default, the script handles the detection of the `dub_id` query parameter and storing it as a first-party cookie:
This is useful for cases where you don't have access to your server-side code, such as when you're using a third-party service like [Google Tag Manager](/docs/integrations/google-tag-manager).

<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>
In this guide, we'll learn how to set up client-side conversion tracking with the Dub Analytics script.

Then, when a conversion event occurs (e.g. a user signs up for an account), you can check for the `dub_id` cookie and attribute the conversion to the original click by [tracking a lead event](/docs/quickstart/server#tracking-lead-events).

<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>

Finally, when the user completes a purchase (e.g. subscribing to a plan, purchasing a product, etc.), you can [track a sale event](/docs/quickstart/server#tracking-sale-events). Under the hood, Dub will automatically attribute the sale to the original link click.

<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>
<ClientSideTrackingWarning />

## Quickstart

Expand Down
1 change: 0 additions & 1 deletion docs/sdks/client-side/features/cross-domain-tracking.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: Cross-domain tracking
description: Track conversions across domains
---

By default, the script already sets the `dub_id` cookie on a **cross-domain level**.
Expand Down
84 changes: 84 additions & 0 deletions docs/sdks/client-side/features/identity-tracking.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: Identity tracking for partner risk monitoring
sidebarTitle: Identity tracking
tag: "Beta"
---

<Note>
Identity tracking is currently only available for select [Dub
Enterprise](https://dub.co/enterprise) customers. [Reach
out](https://dub.co/contact/sales) if you'd like access.
</Note>

The Dub Analytics script also supports [identity tracking](/docs/sdks/client-side/features/identity-tracking) for partner [risk monitoring](/help/article/risk-monitoring).

The [identity variant](/docs/sdks/client-side/variants#identity-variant-script-identity-js) of the script identifies the visitor's device on the paths you configure, and links it to the corresponding partner click, to help you monitor your partner-driven traffic for fraud and abuse.

## Prerequisites

1. You've [set up a partner program](/help/article/setting-up-your-program) on Dub.
2. You've enabled [client-side click tracking](/docs/sdks/client-side/features/click-tracking) on your site.
3. You've enabled [risk monitoring](/help/article/risk-monitoring) in your partner program.

## How identity tracking works

Identity tracking only runs for partner clicks, when the click ID in the `dub_partner_data` cookie matches the `dub_id` cookie. Other clicks that come from non-partner links are skipped.

It runs once per click, on the first page load and on client-side navigation to a matching path. A path matches exactly, and a trailing `/*` also matches everything under the path (for example, `/checkout/*`).

After identifying, the script appends the device's visitor ID to the `dub_id` cookie (`<clickId>_<visitorId>`). Lead and sale tracking send the full value, so pass the cookie as is when you track conversions from your server too. If identification fails, `dub_id` keeps its original value and conversions are still attributed to the partner.

## Setting up identity tracking

Here's how you can set up identity tracking with the Dub Analytics script:

<CodeGroup>

```html HTML
<script
src="https://www.dubcdn.com/analytics/script.identity.js"
data-domains='{"refer": "go.example.com"}'
data-track-identity-paths='["/signup", "/checkout/*"]'
></script>
```

```typescript React/Next.js
// the DubAnalytics component automatically detects the `trackIdentityPaths` prop
// and applies the identity script variant for you
<DubAnalytics
domainsConfig={{ refer: "go.example.com" }}
trackIdentityPaths={["/signup", "/checkout/*"]}
/>
```

</CodeGroup>

If you also track conversions on the client, don't replace your conversion tracking script with `script.identity.js`, or `trackLead` and `trackSale` stop working. Use the [combined variant](/docs/sdks/client-side/variants#combined-variant) `script.conversion-tracking.identity.js` with your existing `data-publishable-key`, plus any other variants you use. The `DubAnalytics` component picks the combined variant for you, unless you set `scriptProps.src`.

<Tip>
We recommend loading the script through a [reverse
proxy](/docs/sdks/client-side/features/reverse-proxy-support), so ad-blockers
don't stop identification.
</Tip>

## Identifying visitors conditionally

If you want to conditionally identify visitors instead, set the paths to an empty list (`trackIdentityPaths={[]}` or `data-track-identity-paths='[]'`) and call `dubAnalytics.trackIdentity()` (or `trackIdentity` from `useAnalytics()`) yourself.

Identification takes a few seconds. If a button on the page sends the visitor to another site right away, like "Sign in with Google", the visitor can leave before it finishes. Wait for `trackIdentity()` before the redirect, with a time limit so sign-in never waits long:

```typescript React/Next.js
const { trackIdentity } = useAnalytics();

async function signInWithGoogle() {
// wait up to 5 seconds for identification
await Promise.race([
trackIdentity(),
new Promise((resolve) => setTimeout(resolve, 5000)),
]);

signIn("google");
}
```

With the script tag, call `dubAnalytics.trackIdentity()` the same way. It returns right away when there is nothing to identify, so other visitors don't wait.
5 changes: 2 additions & 3 deletions docs/sdks/client-side/features/reverse-proxy-support.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
title: Reverse-proxy support
description: Load the Dub Analytics script and send tracking requests through a reverse proxy
---

## Setting up a reverse proxy

To avoid ad-blockers from blocking the Dub Analytics script and its tracking requests, we recommend setting up a reverse proxy.

Depending on which backend framework you're using, there are a few different ways to do this:
Expand All @@ -16,10 +13,12 @@ Depending on which backend framework you're using, there are a few different way
module.exports = {
async rewrites() {
return [
// for client-side tracking requests
{
source: "/_proxy/dub/track/:path*",
destination: "https://api.dub.co/track/:path*",
},
// for the script files
{
source: "/_proxy/dub/:path*",
destination: "https://www.dubcdn.com/analytics/:path*",
Expand Down
19 changes: 3 additions & 16 deletions docs/sdks/client-side/variants.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The base variant of the script is the most lightweight variant of the script. It

- Detecting the `dub_id` query parameter and storing it as a first-party cookie.
- Tracking [client-side click events for referral programs](/docs/sdks/client-side/features/click-tracking).
- Setting [custom cookie window](/docs/sdks/client-side/introduction#custom-cookie-window) and [attribution models](/docs/sdks/client-side/introduction#param-data-attribution-model)
- Setting [custom cookie window](/docs/sdks/client-side/introduction#param-expires-in-days) and [attribution models](/docs/sdks/client-side/introduction#param-data-attribution-model)

Here's how you can use the base variant:

Expand Down Expand Up @@ -101,16 +101,7 @@ Here's how you can use the outbound domains variant:

### Identity Variant (`script.identity.js`)

<Note>
Identity tracking is currently only available for select Dub workspaces.
[Reach out](https://dub.co/contact/support) if you'd like access.
</Note>

The identity variant of the script identifies the visitor's device on the paths you configure, and links it to their partner click for partner [risk monitoring](/help/article/risk-monitoring).

It only runs for partner clicks tracked on the client, with the `?via=` query parameter or the one you set with `data-query-param` (`queryParam` in React), so you also need to set the `refer` domain. It runs once per click, on the first page load and on client-side navigation to a matching path. A path matches exactly, and a trailing `/*` also matches everything under the path (for example, `/checkout/*`).

After identifying, the script appends the device's visitor ID to the `dub_id` cookie (`<clickId>_<visitorId>`). Lead and sale tracking send the full value, so pass the cookie as is when you track conversions from your server too.
The identity variant of the script is a variant of the script that supports [identity tracking](/docs/sdks/client-side/features/identity-tracking) for partner [risk monitoring](/help/article/risk-monitoring).

Here's how you can use the identity variant:

Expand All @@ -135,11 +126,7 @@ Here's how you can use the identity variant:

</CodeGroup>

If you also track conversions on the client, don't replace your conversion tracking script with `script.identity.js`, or `trackLead` and `trackSale` stop working. Use the [combined variant](#combined-variant) `script.conversion-tracking.identity.js` with your existing `data-publishable-key`, plus any other variants you use. The `DubAnalytics` component picks the combined variant for you, unless you set `scriptProps.src`.

We recommend loading the script through a [reverse proxy](/docs/sdks/client-side/features/reverse-proxy-support), so ad-blockers don't stop identification.

To identify conditionally instead, set the paths to an empty list (`trackIdentityPaths={[]}` or `data-track-identity-paths='[]'`) and call `dubAnalytics.trackIdentity()` (or `trackIdentity` from `useAnalytics()`) yourself. Where the law requires consent for device fingerprinting, call it only after the visitor gives consent.
Learn more about setting up identity tracking [here](/docs/sdks/client-side/features/identity-tracking).

### Combined Variant

Expand Down
4 changes: 2 additions & 2 deletions help/article/submitted-leads.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Submitted leads"
description: "Learn how to review and manage submitted leads in Dub."
sidebarTitle: "Submitted leads"
tag: "Beta"
---

<Tip>
This feature is only available on [Advanced plans and
This feature is currently in beta and is only available on [Advanced plans and
above](https://dub.co/pricing).
</Tip>

Expand Down