Recurly affiliate tracking, from signup to renewal.
Recurly affiliate tracking with AffiliateTracking takes one account custom field and one webhook. The first payment credits the affiliate, renewals follow, and refunds and voids come back.
Payments and renewalsRefunds and voidsCloud and self-host
// Example: when a customer signs up
const token = req.cookies.at_token;
await client.createAccount({
code: user.id,
email: user.email,
customFields: [{ name: 'aff_token', value: token }],
});
From click to commission
How a Recurly payment finds its affiliate
The same path as every other sale, with a custom field on the account carrying the token.
- 01The click
A visitor opens an affiliate's link. We record the click, and they land on your site with a signed token.
- 02The script keeps it
t.js saves the token in a cookie on your domain for your attribution window, 30 days unless you change it.
- 03The account carries it
Your server saves the token in the account's aff_token field when it creates the account.
- 04Recurly tells us
The payment arrives, AffiliateTracking reads the field, the 12 fraud rules run, and the account stays linked.
Set it up in four steps
Step 3 is the only code. The rest happens in Recurly and in your settings.
-
Add the script to your site
Paste it on every page, right before </head>. Your workspace settings show the tag with your own address filled in.
<script src="https://yourbrand.affiliatetracking.co/t.js" async></script>
-
Add one custom field in Recurly
Under Configuration, Custom Fields, add a field to Accounts. Keep it off hosted pages, so customers never see it.
# Accounts, custom field API name: aff_token Display name: Affiliate token Hosted pages: Hidden -
Pass the token when you create the account
Read the at_token cookie on your server and send it as the aff_token custom field, like the example above. Creating a purchase instead? The account inside it takes the same field.
-
Add a webhook and a read-only key
Under Integrations, Webhooks, add your address with a username and password. Then make a read-only API key, so AffiliateTracking can read the field. Paste all three into your settings.
# Webhook endpoint (format: XML) https://yourbrand.affiliatetracking.co/webhooks/recurly # Self-host AE_RECURLY_USERNAME="..." AE_RECURLY_PASSWORD="..." AE_RECURLY_API_KEY="read-only key"
What each Recurly notification does
Each notification has to pass the password check, and it counts once, however many times Recurly sends it.
| Recurly notification | What AffiliateTracking does |
|---|---|
| Successful payment, first | Reads aff_token on the account, credits the affiliate and links the account to them for good. |
| Successful payment, renewal | Each renewal credits the linked affiliate. The field isn't needed again. |
| Successful refund | Takes back the same share of the commission. Partial refunds take back part of it. |
| Void payment | Takes back the commission for that payment. |
Good to know before you start
Four details worth knowing before you go live.
Free trials
Your server sets the field when it creates the account. The first paid renewal after the trial earns the commission.
Read-only is enough
The API key only reads accounts. AffiliateTracking never changes anything in your Recurly site.
Your account codes stay yours
Use whatever account code you like. The link lives in the custom field, not the code.
Pick XML
Choose XML as the webhook format when you add the endpoint in Recurly.
Recurly FAQ
How do I run an affiliate program with Recurly?
Recurly bills your customers and AffiliateTracking tracks who sent each one. Add the script, add one account field, pass the token when you create the account and point a webhook at your workspace. Then invite affiliates.
Do I need a developer?
For step 3, yes. It's one extra field wherever your server creates the Recurly account.
Does it work with Recurly.js?
Yes. Recurly.js collects the card, and your server creates the account. That's where the field goes.
What happens when I refund or void a payment?
A refund takes back the same share of the commission, and a void takes back all of it. If you already paid the affiliate, it comes off their next payout.
Does Recurly pay my affiliates?
No. AffiliateTracking works out who's owed what, and you pay them yourself through PayPal, Wise or your bank.
Your Recurly billing,
now with affiliates.
Try cloud free for 14 days. Or buy self-host for $99 once.