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`.
diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx
index 8d7e8fd0..6c32635b 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,47 @@ 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 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.
+
+Here's how you can use the identity variant:
+
+
+
+```html HTML
+
+```
+
+```typescript React/Next.js
+// the DubAnalytics component automatically detects the `trackIdentityPaths` prop
+// and applies the identity script 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.
+
### 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).
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");