API Reference

Tracking API

Use the Tracking API to record affiliate clicks, registrations, and payments from your server. This is the server-side complement to the JavaScript tracking snippet.

If you have a payment gateway integration (Stripe, Paddle, Chargebee), conversions are tracked automatically — you don't need to call the Tracking API for those payments. Use the Tracking API for custom integrations or platforms without a native AFFY integration.

Track a click

Record an affiliate link click. Normally the JavaScript snippet handles this automatically — use this endpoint only if you need server-side click tracking.

POST/api/v1/tracking/click
Request body
json
{
  "clientId": 12345,
  "affiliateReference": "aff_xyz123",
  "clickId": "click_unique_id",
  "sessionId": "session_unique_id",
  "clickedUrl": "https://yourwebsite.com/pricing",
  "referrerUrl": "https://blog.example.com/review",
  "userAgent": "Mozilla/5.0 ...",
  "source": "blog"
}
Response
json
{
  "success": true,
  "clickId": 789,
  "sessionId": "session_unique_id",
  "message": "Click tracked successfully"
}

Track a registration (lead)

Call this endpoint when a referred user registers on your platform. Links the registration to an affiliate click via the session ID stored in their browser cookie.

POST/api/v1/tracking/registration
Request body
json
{
  "clickId": "click_unique_id",
  "email": "customer@example.com",
  "customerId": "your_internal_user_id",
  "customerName": "Jane Smith"
}
Response
json
{
  "success": true,
  "leadId": 456,
  "clickId": "click_unique_id",
  "message": "Registration linked to affiliate referral"
}
The clickId is stored in a cookie by the JavaScript tracking snippet (affy_click_id). Read it from the browser and pass it to your server when the user registers.

Track a lead (registration event)

Alternative endpoint for tracking registration leads with more detail. Use when you want to pass a session ID instead of a click ID.

POST/api/v1/tracking/lead/registration
Request body
json
{
  "clientId": 12345,
  "leadType": "REGISTRATION",
  "customerEmail": "customer@example.com",
  "customerName": "Jane Smith",
  "sessionId": "session_unique_id"
}

Track a payment lead

Track when a referred customer makes a payment outside of a connected gateway.

POST/api/v1/tracking/lead/payment
Request body
json
{
  "clientId": 12345,
  "leadType": "PAYMENT",
  "customerEmail": "customer@example.com",
  "leadValue": 99.00,
  "sessionId": "session_unique_id"
}
Response
json
{
  "success": true,
  "leadId": 456,
  "leadValue": 99.00,
  "conversionSource": "TRACKING_API",
  "message": "Payment linked to affiliate referral"
}

Get tracking status

Check whether a session is associated with an affiliate click. Useful for debugging or verifying tracking is working.

GET/api/v1/tracking/status/{sessionId}
Example request
bash
curl https://api.affy.pro/api/v1/tracking/status/session_unique_id
Response
json
{
  "sessionId": "session_unique_id",
  "hasAffiliate": true,
  "affiliateReference": "aff_xyz123",
  "clickId": 789,
  "clickedAt": "2026-03-01T14:30:00Z"
}

Common integration pattern

Here's a typical server-side integration flow when a user registers:

Server-side registration tracking (Node.js example)
javascript
// 1. Read the affiliate click ID from the request cookie
const clickId = req.cookies.affy_click_id

// 2. Register the user in your system
const user = await createUser({ email, password })

// 3. Report the registration to AFFY (fire and forget)
if (clickId) {
  await fetch('https://api.affy.pro/api/v1/tracking/registration', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      clickId,
      email: user.email,
      customerId: user.id,
      customerName: user.name
    })
  }).catch(err => console.error('AFFY tracking failed:', err))
}