diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..496ee2ca --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/docs.json b/docs.json index e873bb7d..faa62209 100644 --- a/docs.json +++ b/docs.json @@ -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" ] }, { @@ -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" + } ] }, { diff --git a/docs/sdks/client-side/features/click-tracking.mdx b/docs/sdks/client-side/features/click-tracking.mdx index d9f4219a..e5f74fe9 100644 --- a/docs/sdks/client-side/features/click-tracking.mdx +++ b/docs/sdks/client-side/features/click-tracking.mdx @@ -1,6 +1,5 @@ --- 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"; @@ -8,14 +7,14 @@ 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. diff --git a/docs/sdks/client-side/features/conversion-tracking.mdx b/docs/sdks/client-side/features/conversion-tracking.mdx index 3c82f7d1..e9e53cf2 100644 --- a/docs/sdks/client-side/features/conversion-tracking.mdx +++ b/docs/sdks/client-side/features/conversion-tracking.mdx @@ -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). - - A diagram showing how click events are tracked in the conversion funnel - +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). - - - A diagram showing how lead events are tracked in the conversion funnel - - -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. - - - A diagram showing how sale events are tracked in the conversion funnel - + ## Quickstart diff --git a/docs/sdks/client-side/features/cross-domain-tracking.mdx b/docs/sdks/client-side/features/cross-domain-tracking.mdx index 3fc61bd2..d1bb06e7 100644 --- a/docs/sdks/client-side/features/cross-domain-tracking.mdx +++ b/docs/sdks/client-side/features/cross-domain-tracking.mdx @@ -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**. diff --git a/docs/sdks/client-side/features/identity-tracking.mdx b/docs/sdks/client-side/features/identity-tracking.mdx new file mode 100644 index 00000000..8e34564e --- /dev/null +++ b/docs/sdks/client-side/features/identity-tracking.mdx @@ -0,0 +1,84 @@ +--- +title: Identity tracking for partner risk monitoring +sidebarTitle: Identity tracking +tag: "Beta" +--- + + + 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. + + +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 (`_`). 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: + + + +```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](/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`. + + + We recommend loading the script through a [reverse + proxy](/docs/sdks/client-side/features/reverse-proxy-support), so ad-blockers + don't stop identification. + + +## 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. diff --git a/docs/sdks/client-side/features/reverse-proxy-support.mdx b/docs/sdks/client-side/features/reverse-proxy-support.mdx index 38f5a5e1..81db4a2d 100644 --- a/docs/sdks/client-side/features/reverse-proxy-support.mdx +++ b/docs/sdks/client-side/features/reverse-proxy-support.mdx @@ -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: @@ -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*", diff --git a/docs/sdks/client-side/variants.mdx b/docs/sdks/client-side/variants.mdx index 55f4567d..86cf07eb 100644 --- a/docs/sdks/client-side/variants.mdx +++ b/docs/sdks/client-side/variants.mdx @@ -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: @@ -101,16 +101,7 @@ Here's how you can use the outbound domains variant: ### Identity Variant (`script.identity.js`) - - Identity tracking is currently only available for select Dub workspaces. - [Reach out](https://dub.co/contact/support) if you'd like access. - - -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 (`_`). 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: @@ -135,11 +126,7 @@ 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, 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 diff --git a/help/article/submitted-leads.mdx b/help/article/submitted-leads.mdx index ee842a73..6e268d97 100644 --- a/help/article/submitted-leads.mdx +++ b/help/article/submitted-leads.mdx @@ -1,11 +1,11 @@ --- title: "Submitted leads" description: "Learn how to review and manage submitted leads in Dub." -sidebarTitle: "Submitted leads" +tag: "Beta" --- - 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).