Lead Tracking (Signup)
Lead tracking captures when referred visitors sign up or submit forms. This lets you see which partners drive qualified leads—not just clicks.
What It Does
Section titled “What It Does”When a visitor signs up on your site, you call window.affitor.trackLead(). This:
- Captures the lead event with email
- Links it to the stored
partner_codefrom the click - Creates an attribution record in Affitor
Partners can then see: Clicks → Signups → Sales
Prerequisites
Section titled “Prerequisites”Before implementing lead tracking:
- Pageview tracker installed (guide)
- Visitor arrived via affiliate link (has
partner_codecookie)
Basic Implementation
Section titled “Basic Implementation”After your signup form submits successfully, call:
window.affitor.trackLead({ email: 'user@example.com'});That’s the minimum. Email is required; everything else is optional.
Full Implementation
Section titled “Full Implementation”Include additional data for better analytics:
window.affitor.trackLead({ email: 'user@example.com', // Required name: 'John Doe', // Optional phone: '+1234567890', // Optional additional_data: { signup_method: 'email', // How they signed up user_id: 'user_123', // Your internal user ID plan: 'free_trial', // Plan they selected source: 'pricing_page' // Where they signed up }});Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
email | string | Yes | User’s email address |
name | string | No | User’s full name |
phone | string | No | User’s phone number |
additional_data | object | No | Any extra data you want to track |
Integration Examples
Section titled “Integration Examples”Standard Form
Section titled “Standard Form”document.getElementById('signup-form').addEventListener('submit', async function(e) { e.preventDefault();
const email = document.getElementById('email').value; const name = document.getElementById('name').value;
// Your signup logic const result = await createAccount(email, name);
if (result.success) { // Track the lead window.affitor.trackLead({ email: email, name: name, additional_data: { user_id: result.userId, signup_method: 'form' } });
// Redirect to dashboard or next step window.location.href = '/welcome'; }});function SignupForm() { const handleSubmit = async (e) => { e.preventDefault(); const formData = new FormData(e.target);
// Your signup logic const result = await api.createAccount({ email: formData.get('email'), name: formData.get('name') });
if (result.success) { // Track the lead window.affitor?.trackLead({ email: formData.get('email'), name: formData.get('name'), additional_data: { user_id: result.userId } });
router.push('/welcome'); } };
return ( <form onSubmit={handleSubmit}> <input name="email" type="email" required /> <input name="name" type="text" /> <button type="submit">Sign Up</button> </form> );}Google/OAuth Signup
Section titled “Google/OAuth Signup”// After OAuth callbackasync function handleOAuthCallback(user) { // User authenticated via Google/GitHub/etc.
// Track the lead window.affitor?.trackLead({ email: user.email, name: user.name, additional_data: { signup_method: 'google', user_id: user.id } });
// Continue to dashboard window.location.href = '/dashboard';}When to Call trackLead()
Section titled “When to Call trackLead()”Call trackLead() after the signup is confirmed successful:
| Scenario | When to track |
|---|---|
| Form signup | After form validation passes and account is created |
| OAuth signup | After OAuth callback, user authenticated |
| Email verification | After signup, not after verification (track intent) |
| Free trial | When trial starts |
| Waitlist | When added to waitlist |
Don’t track:
- Failed signups
- Duplicate signups
- Bot submissions
Checking for Affitor
Section titled “Checking for Affitor”The tracker might not be loaded if:
- Visitor has ad blocker
- Script failed to load
- Visitor didn’t come from affiliate link
Always check before calling:
if (window.affitor) { window.affitor.trackLead({ email: email });}
// Or use optional chainingwindow.affitor?.trackLead({ email: email });Verifying Lead Tracking
Section titled “Verifying Lead Tracking”Test Mode
Section titled “Test Mode”- Enable debug mode in pageview tracker
- Complete a test signup
- Check browser console for Affitor messages
Dashboard Verification
Section titled “Dashboard Verification”- Visit your site with
?ref=TEST123 - Complete signup flow
- Go to Affitor dashboard → Integration Status
- Lead tracking should show “Connected”
Troubleshooting
Section titled “Troubleshooting”trackLead() Not Working
Section titled “trackLead() Not Working”Check:
window.affitorexists (pageview tracker loaded)- Email parameter is provided
- No JavaScript errors in console
Lead Not Attributed to Partner
Section titled “Lead Not Attributed to Partner”Check:
- Visitor has
partner_codecookie - Visitor came via affiliate link before signing up
- Attribution window hasn’t expired (60 days default)
Duplicate Leads
Section titled “Duplicate Leads”Prevent by:
- Only calling
trackLead()once per signup - Checking signup success before tracking
- Using your internal
user_idto dedupe
Next Steps
Section titled “Next Steps”Lead tracking is set up. Now capture sales: