Syntax
The base script is available onscript.js, and all variants are available on script.[variant].js.
For instance, the outbound-domains variant is available on script.outbound-domains.js.
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.
List of variants
Here’s a list of all the variants available:Base Variant (script.js)
The base variant of the script is the most lightweight variant of the script. It supports the following features:
- Detecting the
dub_idquery parameter and storing it as a first-party cookie. - Tracking client-side click events for referral programs.
- Setting custom cookie window and attribution models
Site Visit Variant (script.site-visit.js)
@dub/analytics site visit feature is still in beta.Outbound Domains Variant (script.outbound-domains.js)
The outbound domains variant of the script is a variant of the script that supports cross-domain tracking across different applications.
On top of the features supported by the base variant, it also supports appending the dub_id cookie to all outbound links targeting the domains you configure.
Here’s how you can use the outbound domains variant:
Combined Variant
You can also mix and match variants. For example, you can use thesite-visit and outbound-domains variants together with this script: script.site-visit.outbound-domains.js.
Here’s how you can use the combined variant:
DubAnalytics React Component
If you’re using a React application, we recommend using the DubAnalytics component to automatically apply the correct script variant for you.
For example, if you want to use the outbound-domains variant, you can do the following:
React
DubAnalytics component will automatically detect the domainsConfig prop and apply the correct script variant for you.