Segment Integration
Use this guide if Segment is already your event hub and you want to send affiliate-relevant backend events to Affonso without building a custom event mapper.
This article is the setup guide. If you need the full request contract, field mapping rules, response behavior, or exact validation details, see the Segment API docs.
💡 Use the dedicated Segment endpoint. New Segment setups should send
events to POST /v1/sources/segment/events.
Before You Start
Make sure you have:
- An Affonso API key with
write:commissionspermission - Segment already sending backend
trackevents for the actions you want to attribute - Your website and affiliate tracking already set up in Affonso
What This Integration Is For
Use Segment when:
- Segment is already your event hub
- you already rely on backend
trackevents - you want Affonso to ingest those events without a separate custom mapping service
This setup currently supports Segment track events only.
Integration Overview
Create a Segment destination
Configure Segment so it forwards the track events you want Affonso to use.
Typical examples include:
Order Completedtrial_startedqualified_leadKYC Passed
Add the Affonso endpoint
Set your destination URL to:
https://api.affonso.io/v1/sources/segment/eventsUse your Affonso API key as a bearer token:
Authorization: Bearer sk_live_your_key_here
Content-Type: application/jsonSend a test event
Send one real or test track event through Segment to confirm the destination
reaches Affonso.
Example:
{
"type": "track",
"event": "Order Completed",
"messageId": "msg_123",
"userId": "user_123",
"properties": {
"revenue": 99,
"currency": "USD"
}
}Verify your identifiers
Make sure each event includes an identifier that Affonso can match to an
existing referral, plus a stable messageId for safe retries.
userId maps to Affonso external_user_id. If you need to send your own
customer_id, put it in properties.customer_id or
properties.customerId. Use customer_id for the customer ID from your
payment provider or billing system, such as Stripe. If you already know the Affonso referral ID, send
properties.referral_id. If your existing setup already uses
properties.affonso_id, that is still accepted.
Troubleshooting Checklist
- Confirm Segment sends
trackpayloads, notidentify,group,page, orscreen - Confirm the destination uses
POST /v1/sources/segment/events - Confirm the API key has
write:commissions - Confirm the event includes a stable identifier that already matches a referral in Affonso
- If you send both
userIdand an explicit external-user field, confirm the values are identical - Confirm
messageIdstays the same when Segment retries delivery - If the event should create a conversion, confirm you send revenue and currency
Tracking Examples
Use these example payloads when you want to trigger different kinds of Affonso events through Segment.
Example: track a signup as lead
{
"type": "track",
"event": "Signup Completed",
"messageId": "msg_signup_001",
"userId": "usr_104982",
"properties": {
"affonso_id": "ref_123",
"affonso_event_type": "lead",
"email": "daniel.harper@northstar-health.io"
}
}Example: track a downstream step as trial
{
"type": "track",
"event": "Trial Started",
"messageId": "msg_trial_001",
"userId": "usr_104982",
"properties": {
"affonso_id": "ref_123",
"affonso_event_type": "trial"
}
}Example: track a specific product conversion
{
"type": "track",
"event": "Downstream Completed",
"messageId": "msg_conversion_001",
"userId": "usr_104982",
"properties": {
"affonso_id": "ref_123",
"affonso_event_type": "conversion",
"product_ids": ["downstream"],
"revenue": 2000,
"currency": "USD"
}
}Use trial only when the event should behave as a trial milestone. If you want
to match a product-specific incentive, send the event as a conversion and
include the matching product_ids or price_ids.
Need The Exact API Contract?
Use the Segment API docs for:
- supported identifier fields
- mapping behavior
- event type normalization
- response behavior
- validation and error details
If you need a fully custom server-side integration without Segment, see Custom Payment Provider API.


