From 62f170af6162016b984848ebe65869b4969519fe Mon Sep 17 00:00:00 2001 From: Rafi Date: Fri, 6 Nov 2026 17:02:18 -0500 Subject: [PATCH 1/6] Document the identity script variant --- docs/sdks/client-side/variants.mdx | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx index 8d7e8fd0..70633d17 100644 --- a/docs/sdks/client-side/variants.mdx +++ b/docs/sdks/client-side/variants.mdx @@ -22,6 +22,7 @@ Here's a list of all the variants available: - [Base Variant](#base-variant-script-js) - [Site Visit Variant](#site-visit-variant-script-site-visit-js) - [Outbound Domains Variant](#outbound-domains-variant-script-outbound-domains-js) +- [Identity Variant](#identity-variant-script-identity-js) - [Combined Variant](#combined-variant) ### Base Variant (`script.js`) @@ -98,6 +99,43 @@ Here's how you can use the outbound domains variant: +### Identity Variant (`script.identity.js`) + + + Identity tracking is only active for workspaces where Dub has turned it on. + + +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. + +It only runs for partner clicks tracked with the `?via=` query parameter, 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 (`_`). Lead and sale tracking send the full value, so pass the cookie as is when you track conversions from your server too. + +Here's how you can use the identity variant: + + + +```html HTML + +``` + +```typescript React/Next.js +// the DubAnalytics component automatically detects the `trackIdentity` prop +// and applies the identity script variant for you + +``` + + + +To identify conditionally instead, set `paths` to an empty list 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. + ### Combined Variant You can also mix and match variants. For example, you can use the `site-visit` and `outbound-domains` variants together with this script: [`script.site-visit.outbound-domains.js`](https://www.dubcdn.com/analytics/script.site-visit.outbound-domains.js). From 099d519bf770c7153093d6917240e52121173f68 Mon Sep 17 00:00:00 2001 From: Rafi Date: Fri, 6 Nov 2026 17:02:18 -0500 Subject: [PATCH 2/6] Add trackIdentity to the install snippet method list --- snippets/client-side-tracking-install.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/client-side-tracking-install.mdx b/snippets/client-side-tracking-install.mdx index 125c74a4..34e30f6a 100644 --- a/snippets/client-side-tracking-install.mdx +++ b/snippets/client-side-tracking-install.mdx @@ -33,7 +33,7 @@ import DubClientInstall from "/snippets/dub-client-install.mdx"; function () { (c[n].q = c[n].q || []).push(arguments); }; - ["trackClick", "trackLead", "trackSale"].forEach( + ["trackClick", "trackLead", "trackSale", "trackIdentity"].forEach( (t) => (c[n][t] = (...a) => c[n](t, ...a)), ); var s = document.createElement("script"); From 372d5e077be1db54aa58cc420e035cded03ab229 Mon Sep 17 00:00:00 2001 From: Rafi Date: Mon, 9 Nov 2026 15:34:50 -0500 Subject: [PATCH 3/6] Rename the identity paths prop and attribute --- docs/sdks/client-side/variants.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx index 70633d17..d513cec1 100644 --- a/docs/sdks/client-side/variants.mdx +++ b/docs/sdks/client-side/variants.mdx @@ -119,22 +119,22 @@ Here's how you can use the identity variant: ``` ```typescript React/Next.js -// the DubAnalytics component automatically detects the `trackIdentity` prop +// the DubAnalytics component automatically detects the `trackIdentityPaths` prop // and applies the identity script variant for you ``` -To identify conditionally instead, set `paths` to an empty list 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. +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. ### Combined Variant From 6da830925a53b637d2db52694b9ddd84c3b40a67 Mon Sep 17 00:00:00 2001 From: Rafi Date: Mon, 9 Nov 2026 16:12:59 -0500 Subject: [PATCH 4/6] Clarify the identity query param and the combined conversion variant --- docs/sdks/client-side/variants.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx index d513cec1..c62289a8 100644 --- a/docs/sdks/client-side/variants.mdx +++ b/docs/sdks/client-side/variants.mdx @@ -107,7 +107,7 @@ Here's how you can use the outbound domains variant: 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. -It only runs for partner clicks tracked with the `?via=` query parameter, 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/*`). +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 (`_`). Lead and sale tracking send the full value, so pass the cookie as is when you track conversions from your server too. @@ -134,6 +134,8 @@ Here's how you can use the identity variant: +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. + 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. ### Combined Variant From 595dcbf4b30203836206879a341ab6ed77fb19cf Mon Sep 17 00:00:00 2001 From: Kiran K Date: Wed, 11 Nov 2026 18:00:49 +0530 Subject: [PATCH 5/6] Recommend one reverse proxy for the script and tracking requests --- .../features/reverse-proxy-support.mdx | 106 +++++------------- 1 file changed, 31 insertions(+), 75 deletions(-) diff --git a/docs/sdks/client-side/features/reverse-proxy-support.mdx b/docs/sdks/client-side/features/reverse-proxy-support.mdx index a3960fab..38f5a5e1 100644 --- a/docs/sdks/client-side/features/reverse-proxy-support.mdx +++ b/docs/sdks/client-side/features/reverse-proxy-support.mdx @@ -1,11 +1,11 @@ --- title: Reverse-proxy support -description: Track clicks on the client-side using a reverse proxy +description: Load the Dub Analytics script and send tracking requests through a reverse proxy --- -## Tracking clicks via a reverse proxy +## Setting up a reverse proxy -To avoid ad-blockers from blocking your click-tracking requests, we recommend 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: @@ -17,8 +17,12 @@ module.exports = { async rewrites() { return [ { - source: "/_proxy/dub/track/:path", - destination: "https://api.dub.co/track/:path", + source: "/_proxy/dub/track/:path*", + destination: "https://api.dub.co/track/:path*", + }, + { + source: "/_proxy/dub/:path*", + destination: "https://www.dubcdn.com/analytics/:path*", }, ]; }, @@ -30,8 +34,12 @@ module.exports = { { "rewrites": [ { - "source": "/_proxy/dub/track/:path", - "destination": "https://api.dub.co/track/:path" + "source": "/_proxy/dub/track/:path*", + "destination": "https://api.dub.co/track/:path*" + }, + { + "source": "/_proxy/dub/:path*", + "destination": "https://www.dubcdn.com/analytics/:path*" } ] } @@ -39,14 +47,24 @@ module.exports = { -Once you've set up your reverse proxy, don't forget to update the `apiHost` parameter in the `` component to point to your proxy URL. + + Rewrites are matched in order, so keep the `track` rule before the catch-all. + The catch-all also serves the files the script loads itself, like the + [identity + variant's](/docs/sdks/client-side/variants#identity-variant-script-identity-js) + agent. + + +## Pointing the script at your proxy + +Once you've set up your reverse proxy, load the script from your proxy and set the API host to your proxy URL. ```javascript HTML // include this script tag in your HTML Head tag -``` - -```typescript React/Next.js -import { Analytics as DubAnalytics } from "@dub/analytics/react"; - -export default function App() { - return ( - - - {/* Your app code here */} - - ); -} -``` - - +Setting `scriptProps.src` stops the `DubAnalytics` component from picking the [script variant](/docs/sdks/client-side/variants) for you, so point it at the variant you use, for example `/_proxy/dub/script.conversion-tracking.identity.js`. From 9734ab6a63abf8734ba60f6777ecb34be5803f12 Mon Sep 17 00:00:00 2001 From: Kiran K Date: Wed, 11 Nov 2026 18:00:49 +0530 Subject: [PATCH 6/6] Link the identity variant to the reverse proxy setup --- docs/sdks/client-side/variants.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx index c62289a8..6c32635b 100644 --- a/docs/sdks/client-side/variants.mdx +++ b/docs/sdks/client-side/variants.mdx @@ -134,7 +134,9 @@ Here's how you can use the identity variant: -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. +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.