Skip to content

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.


When a visitor signs up on your site, you call window.affitor.trackLead(). This:

  1. Captures the lead event with email
  2. Links it to the stored partner_code from the click
  3. Creates an attribution record in Affitor

Partners can then see: Clicks → Signups → Sales


Before implementing lead tracking:

  • Pageview tracker installed (guide)
  • Visitor arrived via affiliate link (has partner_code cookie)

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.


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
}
});
ParameterTypeRequiredDescription
emailstringYesUser’s email address
namestringNoUser’s full name
phonestringNoUser’s phone number
additional_dataobjectNoAny extra data you want to track

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>
);
}
// After OAuth callback
async 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';
}

Call trackLead() after the signup is confirmed successful:

ScenarioWhen to track
Form signupAfter form validation passes and account is created
OAuth signupAfter OAuth callback, user authenticated
Email verificationAfter signup, not after verification (track intent)
Free trialWhen trial starts
WaitlistWhen added to waitlist

Don’t track:

  • Failed signups
  • Duplicate signups
  • Bot submissions

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 chaining
window.affitor?.trackLead({ email: email });

  1. Enable debug mode in pageview tracker
  2. Complete a test signup
  3. Check browser console for Affitor messages
  1. Visit your site with ?ref=TEST123
  2. Complete signup flow
  3. Go to Affitor dashboard → Integration Status
  4. Lead tracking should show “Connected”

Check:

  • window.affitor exists (pageview tracker loaded)
  • Email parameter is provided
  • No JavaScript errors in console

Check:

  • Visitor has partner_code cookie
  • Visitor came via affiliate link before signing up
  • Attribution window hasn’t expired (60 days default)

Prevent by:

  • Only calling trackLead() once per signup
  • Checking signup success before tracking
  • Using your internal user_id to dedupe

Lead tracking is set up. Now capture sales:

Set Up Payment Tracking →