Chargebee affiliate tracking, on every paid invoice.

Chargebee affiliate tracking with AffiliateTracking takes one customer custom field and one webhook. The first paid invoice credits the affiliate, every renewal after follows, and refunds come back.

Invoices and renewalsPassword-checked webhooksCloud and self-host

Your server, opening Chargebee checkoutExample

From click to commission

How a Chargebee invoice finds its affiliate

The same path as every other sale, with a custom field on the customer carrying the token.

  1. 01The click

    A visitor opens an affiliate's link. We record the click, and they land on your site with a signed token.

  2. 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.

  3. 03The customer carries it

    Your server copies the token into the customer's cf_aff_token field when it creates the checkout.

  4. 04Chargebee tells us

    payment_succeeded arrives, the 12 fraud rules run, and the customer stays linked to that affiliate.

Set it up in four steps

Step 3 is the only code. The rest happens in Chargebee and in your settings.

  1. 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.

  2. Add one custom field in Chargebee

    Under Settings, Configure Chargebee, Custom Fields, add a single-line text field to Customers. Keep it off the checkout page, so buyers never see it.

  3. Pass the token at checkout

    When your server creates the checkout or the customer, read the at_token cookie and set it as customer[cf_aff_token], like the example above.

  4. Add a webhook with a password

    Under Settings, Configure Chargebee, Webhooks, add your address, turn on basic authentication and tick three events. Paste the same username and password into AffiliateTracking.

What each Chargebee event does

Each event has to pass the password check, and it counts once, however many times Chargebee sends it.

Invoices for $0, like a trial, earn nothing.
Chargebee eventWhat AffiliateTracking does
payment_succeeded, firstReads cf_aff_token on the customer, credits the affiliate and links the customer to them for good.
payment_succeeded, laterRenewals and upgrades credit the linked affiliate. The field isn't needed again.
payment_refundedTakes back the same share of the commission. Partial refunds take back part of it.
credit_note_createdA refund credit note on a paid invoice takes back the same share.

Good to know before you start

Four details worth knowing before you go live.

Free trials

Your server sets the field when the customer signs up. Their first paid invoice after the trial earns the commission.

First affiliate keeps them

If a linked customer comes back through another link, the first affiliate still gets their renewals.

Pick a long password

Chargebee sends the username and password with every event. Make the password long and random, and use it nowhere else.

Use the exact API name

The field has to be cf_aff_token. Chargebee builds the API name from the field name, so check it before you save.

Chargebee FAQ

How do I run an affiliate program with Chargebee?

Chargebee bills your customers and AffiliateTracking tracks who sent each one. Add the script, add one custom field, pass the token at checkout and point a webhook at your workspace. Then invite affiliates.

Do I need a developer?

For step 3, yes. It's one extra parameter wherever your server creates the Chargebee checkout or customer.

Does it work with Chargebee's drop-in checkout?

Yes. The drop-in script asks your server for a hosted page, and your server sets the field when it creates that page.

What happens when I refund an invoice?

The same share of the commission comes back. If you already paid the affiliate, it comes off their next payout.

Does Chargebee pay my affiliates?

No. AffiliateTracking works out who's owed what, and you pay them yourself through PayPal, Wise or your bank.

Your Chargebee billing,
now with affiliates.

Try cloud free for 14 days. Or buy self-host for $99 once.