Conversion tracking requires a Business plan
subscription or higher.
lead
event happens when a user performs an action that indicates interest in your product or service. This could be anything from:
- Signing up for an account
- Booking a demo meeting
- Joining a mailing list

Prerequisites
First, you’ll need to enable conversion tracking for your Dub links to be able to start tracking conversions:If you’re using Dub Partners, you can skip this step
since partner links will have conversion tracking enabled by default.
Option 1: On a workspace-level
Option 1: On a workspace-level
To enable conversion tracking for all future links in a workspace, you can do the following:
To enable conversion tracking for all future links in a workspace, you can do the following:
This option will enable conversion tracking in the Dub Link Builder for all future links.
- Navigate to your workspace’s Analytics settings page.
- Toggle the Workspace-level Conversion Tracking switch to enable conversion tracking for the workspace.

Option 2: On a link-level
Option 2: On a link-level
If you don’t want to enable conversion tracking for all your links in a workspace, you can also opt to enable it on a link-level.To enable conversion tracking for a specific link, open the Dub Link Builder for a link and toggle the Conversion Tracking switch.

You can also use the
C
keyboard shortcut when inside the link builder to
quickly enable conversion tracking for a given link.Option 3: Via the API
Option 3: Via the API
Alternatively, you can also enable conversion tracking programmatically via the Dub API. All you need to do is pass
trackConversion: true
when creating or updating a link:@dub/analytics
script to your website to track conversion events.
You can install the @dub/analytics
script in several different ways:
You can verify the installation with the following tests:
- Open the browser console and type in
_dubAnalytics
– if the script is installed correctly, you should see the_dubAnalytics
object in the console. - Add the
?dub_id=test
query parameter to your website URL and make sure that thedub_id
cookie is being set in your browser.
- The analytics script was added to the
<head>
section of the page - If you’re using a content delivery network (CDN), make sure to purge any cached content

Option 1: Using HubSpot Forms
HubSpot Forms help you capture lead information and track conversions. By integrating with Dub, you can attribute each form submission back to the specific Dub link that drove the conversion. To make attribution work, you need to capture thedub_id
cookie in your HubSpot form. This ensures each lead is tied back to the exact Dub link they came from.
Here’s how you can set it up:
1
Create a new property
In HubSpot, create a new property under the Contact object:
- Label: Dub Id
- Group: Contact information
- Field type: Single-line text
- Visibility options: set to Show property in forms and bots
- Internal name: must be
dub_id

2
Add a hidden field to your form
In the HubSpot form builder, add a hidden field and map it to the Dub Id
property you just created.This makes sure the value captured by your script is stored on the contact record. Without mapping to a property, HubSpot won’t persist the 
dub_id
value.
3
Add the script to your site
Finally, add the following snippet to your site. The script reads the When the form is ready, the script checks for the
dub_id
cookie and, if found, automatically fills the hidden Dub Id form field with its value.dub_id
and, if found, automatically sets it into a hidden Dub Id
field on the form.This way, when a prospect submits the form, the dub_id
is captured and passed to HubSpot, ensuring the lead is attributed back to the original Dub link.Option 2: Using HubSpot Meeting Scheduler
HubSpot’s Meeting Scheduler lets prospects book time directly with you or your team. Since HubSpot doesn’t let you add a hidden field to the scheduling form, you should handle initial lead tracking through deferred lead tracking on the client side.1
Generate your publishable key
Before you can track conversions on the client-side, you need to generate a publishable key from your Dub workspace.To do that, navigate to your workspace’s Analytics settings page and generate a new publishable key under the Publishable Key section.

2
Allowlist your site's domain
Then, you’ll need to allowlist your site’s domain to allow the client-side conversion events to be ingested by Dub.To do that, navigate to your workspace’s Analytics settings page and add your site’s domain to the Allowed Hostnames list.This provides an additional layer of security by ensuring only authorized domains can track conversions using your publishable key.
You can group your hostnames when adding them to the allow list:

example.com
: Tracks traffic only fromexample.com
.*.example.com
: Tracks traffic from all subdomains ofexample.com
, but not fromexample.com
itself.
When testing things out locally, you can add
localhost
to the Allowed
Hostnames list temporarily. This will allow local events to be ingested by
Dub. Don’t forget to remove it once you’re ready to go live!3
Add the tracking code to your site
Use the following code to track lead conversions when meetings are booked through the HubSpot scheduler.The script listens for booking events from HubSpot, extracts the customer’s details (name and email), and then calls
dubAnalytics.trackLead()
with deferred lead tracking.This way, the lead is only tracked after the meeting is confirmed, ensuring accurate attribution.