Installation
Add the script to the<head> section of your HTML:
The
defer attribute ensures the script loads asynchronously without blocking page rendering.How It Works
The analytics script automatically:- Detects when a user arrives via a Dub short link
- Extracts the unique click ID from the URL (
dub_idparameter) - Stores it as a first-party cookie on your domain
- Makes it available for conversion tracking
Manual Installation
For websites where you can edit the HTML:Google Tag Manager Installation
For centralized tag management, use Google Tag Manager:Create a New Tag
- Navigate to your Google Tag Manager account
- Click Tags in the left sidebar
- Click the New button
- Select Custom HTML as the tag type
Configure the Trigger
- Click on the Triggering section
- Select All Pages as the trigger type
- This will load the script on every page
Verification
Verify the script is working correctly:Check Cookie Storage
- Click on one of your Dub short links
- Open browser DevTools (F12)
- Go to Application → Cookies
- Look for the
dub_idcookie
Check Console
The script logs debug information to the console:Cookie Configuration
The script stores click IDs with these defaults:- Cookie Name:
dub_id - Duration: 30 days
- Domain: Current domain
- Path:
/ - SameSite:
Lax - Secure:
true(HTTPS only)
Advanced Configuration
Customize the script behavior with configuration options:Tracking Conversions
After the script is installed, retrieve the click ID server-side to track conversions:WordPress Integration
Using a Plugin
Install a “Header and Footer Scripts” plugin, then add the script to the header section.Manual Installation
Edit your theme’sheader.php file:
Shopify Integration
Add the script to your Shopify theme:- Go to Online Store → Themes
- Click Actions → Edit code
- Open
theme.liquid - Add the script before
</head>:
Performance Impact
- Size: ~2KB gzipped
- Load Time: Asynchronous (non-blocking)
- Execution: < 1ms
- Network: Single HTTP request
Troubleshooting
Script Not Loading
- Check for ad blockers or privacy extensions
- Verify the script URL is correct
- Check browser console for errors
Cookie Not Set
- Ensure the URL has
dub_idparameter - Check cookies are enabled in browser
- Verify HTTPS is enabled (required for secure cookies)
Multiple Domains
For cross-domain tracking, configure the cookie domain:Next Steps
React Component
Use React components instead
Track Conversions
Learn about conversion tracking
Next.js Integration
Integrate with Next.js
API Reference
Explore the API