The attribution chain
Every conversion follows this path:Click tracking
When a visitor clicks an affiliate’s referral link, AgentRef’s tracking script handles attribution automatically:-
Referral link redirect. The visitor clicks a link like
https://www.agentref.co/r/abc123. AgentRef resolves the affiliate code, records the click, and redirects to the target URL. -
Cookie placement. The tracking script sets first-party cookies on your domain:
agentref_cid– a click identifier for conversion matchingagentref_src– the traffic sourceagentref_pid– the active program ID
- Cookie duration. Cookies persist for your configured duration (default: 30 days). If a visitor returns within that window and converts, the affiliate still gets credit.
- Click deduplication. Multiple clicks from the same visitor within a short window are deduplicated to prevent inflated metrics.
The tracking script is a lightweight, first-party JavaScript snippet that runs on your domain. It does not use third-party cookies or fingerprinting.
Conversion attribution
When a tracked visitor makes a purchase, AgentRef connects the sale to the affiliate:-
Stripe webhook. After a successful payment, Stripe sends a
checkout.session.completed(orinvoice.paidfor subscriptions) webhook to AgentRef. -
Metadata matching. AgentRef looks for the
agentref_cidin the Stripe session metadata. This links the payment back to the original click. -
Conversion record. A conversion is created with status
pending. It includes the revenue amount, the affiliate ID, and the click that drove the sale. - Last-click attribution. If multiple affiliates drove clicks for the same visitor, the most recent click before conversion wins. This is the industry-standard attribution model.
How metadata flows into Stripe
For Stripe Payment Links, Buy Buttons, and Pricing Tables, the tracking script automatically instruments the hosted Stripe surface with the click token viaclient_reference_id – no server code needed.
For server-created Checkout Sessions, you read the metadata from the tracking script on the client side and pass it to your server:
Commission calculation
Once a conversion is recorded, AgentRef calculates the affiliate’s commission based on your program settings:| Commission type | How it works |
|---|---|
| Percentage (one-time) | Affiliate earns a percentage of the sale amount. Example: 20% of a 20 commission. |
| Percentage (recurring) | Affiliate earns a percentage on every subscription payment. Continues for the lifetime of the subscription or until a configured limit. |
| Recurring with limit | Same as recurring, but capped at a number of months. Example: 20% for the first 12 months. |
Fraud detection
Every conversion passes through automated fraud checks before commissions are approved:- Duplicate click detection. Flags unusual click patterns from the same IP or device within a short timeframe.
- Self-referral detection. Catches affiliates who try to refer themselves by matching affiliate identity against the buyer.
- Suspicious conversion patterns. Identifies statistically unusual spikes in conversions that deviate from an affiliate’s normal baseline.
- Geographic anomalies. Flags when click geography and conversion geography don’t match expected patterns.
review_flag tool.
Payouts
When an affiliate’s approved commissions reach the payout threshold, they become eligible for payout:- Threshold check. Default payout threshold is $50 (configurable per program). Commissions accumulate until this amount is reached.
- Payout schedule. Payouts are processed on your configured frequency: weekly, monthly, or quarterly.
- Payout execution. AgentRef creates the payout record and handles the commission state transitions. You complete the actual payment through your preferred method (Stripe, PayPal, Wise, bank transfer).
-
CSV export. For bulk payouts, export a CSV in PayPal, Wise, SEPA, or generic format using the
export_payouts_csvtool or API endpoint.
Conversion status flow
Every conversion moves through a defined lifecycle:- Pending – Conversion recorded, awaiting fraud checks and approval window.
- Approved – Passed all checks. Commission is locked in and counts toward payout.
- Rejected – Failed fraud checks or manually rejected by merchant.
- Paid – Commission has been included in a completed payout.
- Refunded – The original Stripe payment was refunded. Commission is reversed.
Integration points
AgentRef provides multiple ways to integrate with your stack:| Integration | Purpose | Best for |
|---|---|---|
| Tracking script | Captures clicks and sets attribution cookies on your domain. | All merchants – required for click tracking. |
| Stripe webhooks | Automatically creates conversions from Stripe payment events. | All merchants using Stripe. |
| REST API | Full programmatic access to all AgentRef resources. | Custom integrations, backend automation. |
| MCP server | OAuth-ready tools, resources, and prompts for AI assistants. | Claude, Codex, Cursor, OpenClaw, and custom agent workflows. |
| Webhooks (outgoing) | Receive real-time notifications for 13 event types (program, affiliate, conversion, payout, flag events). | Custom workflows, CRM sync, notifications. |
| Node.js SDK | Type-safe API client for JavaScript/TypeScript projects. | Node.js backends and scripts. |
| Python SDK | API client for Python projects. | Python backends, data analysis, automation scripts. |
Next steps
Quickstart
Set up your first program in 5 minutes.
Agent Setup
Connect AgentRef to your AI assistant via MCP.