Skip to main content
Referly tracks Chargebee subscriptions by storing the referral on the customer in Chargebee. That one decision shapes the whole integration: because the referral lives on the customer rather than on a single checkout, every invoice that customer is ever billed carries it — so renewals, upgrades, and plan changes all keep earning the affiliate their commission with no extra work. Setting it up takes four things: the tracking script on your site, a custom field in Chargebee to hold the referral, a small piece of code to fill that field in at checkout, and a webhook so Chargebee tells Referly when money moves. A fifth, optional step connects your API key so Referly can read your plan names for product-level commission.
Chargebee is the most hands-on of Referly’s payment integrations — you create the custom field and the webhook yourself. Set aside 20 minutes and work through the steps in order.

What the Chargebee integration can and can’t do

Before you start

You’ll need:
  • Admin access to your Chargebee site, so you can add a custom field, a webhook, and an API key.
  • The ability to add code to your website, or someone who can.
  • Your Referly integration guide open. In Referly, open your program, go to Settings, then Integrations, and pick the card that matches how you take payments: Chargebee Drop-In, Chargebee Payment Links, or Chargebee API. Your webhook address is shown there, already filled in with your program’s details.

Step 1: Install the tracking script on your site

The tracking script recognises visitors who arrived from an affiliate link, records the click, and remembers who referred them until they subscribe. Copy the snippet from Step 1 of your Chargebee guide in Referly — it comes pre-filled with your program ID — and paste it inside the head section of your website, on every page.
Tracking script
If you use Google Tag Manager, switch to the Using Google Tag Manager tab in the guide for that version instead.

Step 2: Create the custom field in Chargebee

This is the field that holds the referral against each customer. Get the API name exactly right — Referly looks for that specific name and nothing else.
1

Open custom fields

In your Chargebee dashboard, go to Settings, then Configure Chargebee, then Custom Fields.
2

Add a customer field

Choose Customer as the object the field belongs to, and Single line text as its type.
3

Name it

Set the Label to pushlap_affiliate_id and the API Name to cf_pushlap_affiliate_id. Chargebee usually adds the cf_ prefix for you — check that the final API name matches exactly.
4

Save

Save the field. It’s now available on every customer in your site.
If you create customers through Chargebee’s API rather than a hosted checkout, you can skip this field and put the referral in the customer’s metadata instead, under the key pushlap_affiliate_id. Referly checks both places.

Step 3: Send the referral into Chargebee

Pick the tab that matches how your customers subscribe. In every case the snippet goes near the bottom of the page, just before the closing body tag, on the pages where checkout happens — and the tracking script from Step 1 has to be on the same page.
Use this if you open Chargebee’s in-page checkout with Chargebee.js. It sets the custom field on the cart’s customer before checkout opens.
Chargebee drop-in

Step 4: Add the Referly webhook in Chargebee

This is how Chargebee tells Referly that a subscription started or an invoice was paid. Without it, nothing reaches Referly at all.
1

Open webhook settings

In your Chargebee dashboard, go to Settings, then Configure Chargebee, then API Keys and Webhooks, and open the Webhooks tab. Select Add Webhook.
2

Name it

Set the Webhook Name to Referly Integration, or anything else you’ll recognise later.
3

Paste the webhook address

Copy the webhook address from your Chargebee guide in Referly and paste it into the Webhook URL field. It already includes your program’s details, so copy it rather than typing it out.
4

Set the API version

Choose Version 2. Referly reads Chargebee’s version 2 format.
5

Choose the events

Rather than leaving All Events selected, pick these seven:
  • Subscription Created
  • Subscription Started
  • Subscription Activated
  • Subscription Cancelled
  • Subscription Deleted
  • Payment Succeeded
  • Payment Refunded
6

Exclude card information

Turn on Exclude Card Information. Referly has no use for card details, and there’s no reason to send them anywhere they aren’t needed.
7

Save

Save the webhook. Chargebee allows up to five webhooks per site, so this sits alongside any you already have.
Test sites and live sites in Chargebee are entirely separate. A webhook added on your test site won’t send anything from your live site — add it on both if you plan to test first, and remember each site has its own API keys too.

Step 5: Connect your API key for plan-level detail

This step is optional but strongly recommended. It lets Referly look up the plans on each invoice, which is what puts plan names on your sales and makes different commission rates per plan possible.

Create the key in Chargebee

1

Open API keys

In your Chargebee dashboard, go to Settings, then Configure Chargebee, then API Keys and Webhooks, and open the API Keys tab. Select Add API Key.
2

Choose the key type

Choose a Read-Only Key. Referly only reads your plans — it never changes anything in Chargebee — so there’s no reason to hand over write access.
3

Copy the key

Copy it as soon as it’s created and keep it somewhere safe. Chargebee’s API key documentation covers key types in more detail.
4

Note your site name

Your site name is the first part of your Chargebee address. If you sign in at mysite.chargebee.com, your site name is mysite — that part only, with no .chargebee.com on the end.

Enter them in Referly

1

Open the integrations dialog

In Referly, open your program, go to Settings, then Integrations, select Connect Integration in the top right, and choose Chargebee.
2

Fill in both fields

Paste your key into API key and your site name into Site.
3

Connect

Select Connect. If it works, a green Connected badge appears with your site name.
These fields lock once saved. To change the key or point at a different site, select Disconnect and connect again.

Step 6: Test the whole flow

1

Use your Chargebee test site

Add the custom field, the webhook, and the API key on your test site, and point your test page at your test site’s checkout.
2

Visit your site through an affiliate link

Use a real affiliate’s referral link from your Affiliates page, in a private window.
3

Check the click landed

In Referly, open that affiliate’s record and confirm the click count went up.
4

Subscribe

Go through your checkout and subscribe with one of Chargebee’s test cards.
5

Check the customer in Chargebee

Open the new customer in your Chargebee dashboard and look at the pushlap_affiliate_id field. If it’s empty, the Step 3 snippet didn’t run — that’s the single most common failure, and everything downstream depends on it.
6

Check the result in Referly

Open Customers to find the buyer attached to the affiliate, Sales to confirm the invoice amount and the plan, and Rewards to see the commission.
7

Switch to live

Repeat Steps 2, 4, and 5 on your live site, point your checkout back at live, and delete your test customers and sales from Referly so they don’t skew your reporting.

What happens automatically once you’re set up

The customer becomes a referred customer in Referly, attached to the affiliate stored on their Chargebee record, with their plan name. A trial subscription lands here too, before any money has moved.
The invoice becomes a sale and the commission is worked out from the affiliate’s plan. Tax comes across, and the plans on the invoice come across as line items if you connected your API key.
Every renewal invoice raises another sale, credited to the same affiliate, because the referral is stored on the customer rather than on one checkout. This is what makes recurring commissions work.
See Refunds below.

Refunds

When a payment is refunded in Chargebee, Referly finds the matching sale and marks it as refunded, so no commission is owed on money you gave back. This only applies while the commission is still on hold. Once the affiliate has been cleared for payout on that sale, it’s left alone — adjust it by hand if you want it reversed. See Refunds and Reward holds.

Disconnecting

There are two parts, and they’re independent:
  • To stop tracking, delete the Referly webhook in your Chargebee dashboard under Settings, then Configure Chargebee, then API Keys and Webhooks. Nothing reaches Referly after that.
  • To remove your API key, open Connect Integration in Referly, select Chargebee, and choose Disconnect. You can also revoke the key on Chargebee’s side.
Removing the API key alone doesn’t stop tracking — sales still arrive through the webhook, they just lose their plan-level detail. Nothing already tracked is deleted. Anything that happens while the webhook is gone is not recorded and won’t be picked up later.

Troubleshooting

Work backwards. Open a recent customer in Chargebee and check whether the pushlap_affiliate_id field has a value. If it’s empty, the problem is the Step 3 snippet. If it has a value, check the webhook in Chargebee — that it exists, uses Version 2, and has the seven events selected.
Three things to check: the API name is exactly cf_pushlap_affiliate_id, the tracking script from Step 1 is on the same page as the checkout snippet, and the visitor actually arrived through an affiliate link. Test in a private window with a referral link.
The subscription events are getting through and the payment event isn’t. Check that Payment Succeeded is selected on your webhook in Chargebee.
That’s the API key connection from Step 5 missing or wrong. Check that the site name is the short name only — mysite, not mysite.chargebee.com — and that the key belongs to the same site the sales are coming from.
Chargebee keeps test and live completely separate. The custom field, the webhook, and the API key all have to be created again on your live site.
Open the customer in Chargebee and confirm the referral is still stored against them. If someone cleared the field or the customer was recreated, later invoices have nothing to match on. You can set the field on the customer by hand to fix it going forward.

Commission plans overview

Set what affiliates earn on first payments and renewals.

Product-based commissions

Pay different rates on different Chargebee plans.

Universal integration

Track sign-ups and leads that never reach Chargebee.

Refunds

How refunded sales affect what your affiliates are owed.
Last modified on July 21, 2026