@dub/analytics is a lightweight (~1kb), open-source client-side script used for tracking conversions with Dub Conversions.
The script handles the detection of the dub_id query parameter and storing it as a first-party cookie, which will be used to attribute subsequent conversion events to the original link.

?via=john). This gives you the flexibility to track clicks directly on your website or app, without needing to rely on link redirects.
Installation guides
Based on the framework or platform you’re using, you can install the script in different ways:React
Add Dub Analytics to your React app.
Manual installation
Add Dub Analytics to your website.
Framer
Add Dub Analytics to your Framer site.
Shopify
Add Dub Analytics to your Shopify store.
WordPress
Add Dub Analytics to your WordPress site.
Webflow
Add Dub Analytics to your Webflow site.
Concepts
You can pass the following props to the@dub/analytics script to customize its behavior:
The base URL for the Dub API. This is useful for setting up reverse
proxies
to avoid adblockers.
The attribution model to use for the analytics event. The following
attribution models are available:
first-click: The first click model gives all the credit to the first touchpoint in the customer journey.last-click: The last click model gives all the credit to the last touchpoint in the customer journey.
Custom properties to pass to the cookie. Refer to
MDN’s Set-Cookie documentation for
all available options.
Configure the domains that Dub will track. The following properties are available:
[Deprecated: Use
data-domains.refer instead] The Dub custom domain for
referral program client-side click trackingThe query parameter to listen to for client-side click-tracking (e.g.
?via=abc123).Examples
Here are some code examples to learn how to use the script:Cross-domain tracking
By default, the script already sets thedub_id cookie on a cross-domain level.
This means that if you have the script installed on your marketing site (e.g. example.com), the cookie will also be accessible when your user signs up for your app (e.g. app.example.com).
However, if you are installing the script on a subdomain (e.g. app.example.com), you will need to set the following option to make sure the cookie is accessible on the apex domain as well (e.g. example.com):
outboundDomains prop to ensure that the dub_id cookie value is automatically appended to all outbound links targeting your main domain (e.g. example.com).
Custom cookie window
By default, the script sets thedub_id cookie to expire in 90 days. You can customize this behavior by passing the cookieOptions prop to the script:
Load the script via a reverse proxy
To avoid ad-blockers from blocking the@dub/analytics script, it is recommended to use a reverse proxy.
Depending on which backend framework you’re using, there are a few different ways to do this:
scriptProps.src parameter in the <Analytics /> component to point to your proxy URL.