Refficks

Chargebee affiliate tracking with Refficks

Chargebee reports every paid invoice, refund and chargeback to Refficks, so subscription revenue credits the partner who brought the customer.

Nobody has walked these steps against a real Chargebee setup yet. They are built from the provider's documentation, listed at the bottom of this page.

What it gives you

  • Every paid invoice (a first payment, each renewal, a one-off charge) is recorded as a sale on its value before tax, however the customer paid: cash, Chargebee credits, or both.
  • A refund takes back its share of the commission; a chargeback or a payment the bank reversed takes it back too.
  • Subscriptions are kept in step: trials, plan changes, pauses, cancellations and reactivations show on the customer's card.
  • A partner's code on an invoice credits that partner.

What it does not

  • Chargebee signs nothing it sends. The password proves a delivery came from your webhook; Refficks cannot yet ask Chargebee to confirm a payment, or fetch one it gave up sending after three days.
  • Past invoices are not imported: Refficks counts what Chargebee sends from now on.
  • An invoice paid in parts is counted once, when the last part arrives.
  • A chargeback reaches Refficks only if Chargebee records it, with its Chargeback Management on and set to record a refund. Won back, it is not given back on its own: credit the partner by hand.
  • In-app purchases Chargebee copies from the App Store or Google Play are not counted here, so they are never paid twice.

Steps

These are the steps as they read inside Refficks. Where one says “below”, it means this guide's page in Refficks, where your own script, addresses and checks are.

  1. 1. Connect Chargebee

    Say below whether this is your live site or your test site, and press Connect. Refficks shows you an address, a username and a password. The password is shown once.

    In Chargebee, open Settings → Configure Chargebee → Webhooks and add a webhook. Paste the address, turn on "Protect webhook URL with basic authentication", paste the username and password, and choose API version 2.

    Leave every event selected. Refficks counts payments, refunds and chargebacks, keeps subscriptions in step, and records the rest with the reason it was not counted.

    The connection is made on this guide in Refficks, once you have an account.

  2. 2. Put the Refficks script on your site

    Every page, including the ones with your Chargebee checkout. Chargebee knows its own customers, never the visit, so a buyer reaches Refficks from Chargebee as somebody it has never seen unless your site said who they were.

    Your copy of the Refficks script, with your own key in it, is on the Integrations page in Refficks.

  3. 3. Create the custom field refficks_visitor in Chargebee

    In Chargebee, open Settings → Configure Chargebee → Custom Fields and create a text field with the API name "refficks_visitor" on Customers, and another on Subscriptions. Hide both from customers.

    Publish them to your live site. Chargebee creates custom fields on the test site first, and an unpublished field never reaches a live checkout: the visitor is dropped without a word.

  4. 4. On Chargebee's checkout

    Recommended, if your pages open Chargebee's checkout with Chargebee.js (the drop-in script, data-cb-type="checkout" buttons, or Chargebee.getInstance()). Put the script below after both Chargebee.js and the Refficks script. It hands the checkout the visitor id the Refficks script keeps for this browser, and Chargebee puts it in refficks_visitor on the customer and the subscription.

    It writes nothing while the visitor has not agreed to cookies, and takes the id back off if they withdraw. It never writes a partner's code: which partner brought the visitor is Refficks's to work out from the visit.

    The code for this step is written for your account, and is on this guide in Refficks.

  5. 5. Or from your own server

    If your server creates the checkout or the subscription through Chargebee's API, set refficks_visitor from the rk_vid cookie the Refficks script keeps on your own domain, as below. meta_data.refficks_visitor works as well.

    Set it when the subscription is created. A field set afterwards reaches Refficks only with the next thing Chargebee sends, so the first payment is not credited to anybody.

    The code for this step is written for your account, and is on this guide in Refficks.

  6. 6. Or give each Chargebee customer your own user id

    Create each Chargebee customer with the id your app already uses for the person (customer[id]), and say the same id to Refficks when they sign up or sign in, with the script below. A Chargebee invoice for that customer is then a sale by somebody Refficks knows.

    Use an id nobody can guess, such as your user id, not a sequential number: anybody can say any id to Refficks from a browser.

    The code for this step is written for your account, and is on this guide in Refficks.

  7. 7. Give each partner their code in Chargebee

    Create each partner's discount code as a coupon, or a code in a coupon set, spelt the same. An invoice paid with that code is credited to that partner.

  8. 8. Send a test

    Press Test Webhook on the webhook in Chargebee. It arrives below and says the connection works; nothing in it is credited.

Sources

Have an account? Open this guide in Refficks for your own script and the checks that show when it is working. New to Refficks? Create an account.

More in Checkouts and billing