Signup Tracking
After a user registers, notify Affitor so the signup is linked to the referring affiliate partner.
Browser-Side (requires tracker script)
// Call after signup succeeds
await window.affitor.signup(user.id, user.email);
With the npm SDK:
import { loadAffitor } from '@affitor/tracker';
const affitor = await loadAffitor('YOUR_PROGRAM_ID');
await affitor?.signup(user.id, user.email);
Server-Side (Lead API)
POST https://api.affitor.com/api/v1/track/lead
Authorization: Bearer YOUR_PROGRAM_API_KEY
Content-Type: application/json
{
"customer_key": "user_123",
"email": "user@example.com",
"click_id": "from_affitor_click_id_cookie"
}
Node.js
await fetch('https://api.affitor.com/api/v1/track/lead', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.AFFITOR_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
customer_key: newUser.id,
email: newUser.email,
click_id: req.cookies.affitor_click_id,
}),
});
Python
requests.post(
'https://api.affitor.com/api/v1/track/lead',
headers={
'Authorization': f'Bearer {AFFITOR_API_KEY}',
'Content-Type': 'application/json',
},
json={
'customer_key': str(new_user.id),
'email': new_user.email,
'click_id': request.cookies.get('affitor_click_id'),
},
)
Rules
- Provide at least one of
click_idorcustomer_key - The
customer_keymust be your internal user ID, reused later in sale tracking - Browser-side
signup()is simplest when the tracker is already on the page
Test
npx affitor test lead