Connect Chargebee so Tolt can track the customers your partners refer and the payments they make. You add your Chargebee site and key, add Tolt's tracking script to your site, send each customer's referral ID to Chargebee and set up a webhook.
Add the integration
Go to Settings › Integrations and click Add integration.
Select Chargebee and click Continue with Chargebee.
Under Add Chargebee site, enter your Chargebee site domain, without
https://or a trailing slash.In Chargebee, go to Developer Tools, open the API Authentication tab and copy the Public API key.
Paste it into Add your Chargebee Public API key in Tolt.
Add the tracking script
Copy the script from Add the Tolt tracking script to your site and paste it into your website's <head> tag. Add it to every page, including your landing pages and app pages, so no visit through a partner link is missed.
Send the referral ID to Chargebee
The script stores the visitor's referral ID in window.tolt_referral. How you send it to Chargebee depends on how you integrate Chargebee. Tolt shows both methods under Choose one or more methods to integrate with Chargebee.
Drop-in script
In Chargebee, go to Settings › Configure Chargebee › Custom Fields.
Create a customer field with the API value
cf_tolt_referral.On the page with your Chargebee checkout, set the field to the referral ID. This JavaScript example does it once the Tolt script has loaded:
if (window.tolt_referral) {
var cbInstance = Chargebee.getInstance();
var cart = cbInstance.getCart();
cart.setCustomer({
cf_tolt_referral: window.tolt_referral
})
}
API based
Send window.tolt_referral from your front end to your server, then add it as tolt_referral in meta_data when you create the customer. This TypeScript example uses Chargebee's SDK:
import { ChargeBee } from 'chargebee-typescript';
var chargebee = new ChargeBee();
chargebee.configure({site: "{site}", api_key: "{site_api_key}"});
chargebee.customer.create({
first_name: "Jane",
last_name: "Doe",
email: "[email protected]",
meta_data: {
tolt_referral: referralId // the value of window.tolt_referral
}
}).request(function(error, result) {
if (error) {
console.log(error);
}
});
Both examples are starting points. Adjust them to fit how your checkout works.
Set up the webhook
In Chargebee, go to Settings › Configure Chargebee › Webhooks and click Add Webhook.
Enter these details:
Webhook name:
Tolt IntegrationWebhook URL: the URL shown under Setup your webhooks in Tolt. It looks like
https://api.tolt.io/webhooks/chargebee?id=YOUR-ID.API version: v2
Select these events:
Subscription Created
Subscription Started
Subscription Deleted
Subscription Canceled
Payment Succeeded
Payment Refunded
Coupon Deleted
Switch on Exclude card information from webhook call.
Save the webhook.
Save the integration
Optionally, under Extra, switch on Exclude Chargebee tax in the tracking amount to calculate commissions without tax.
Click Save integration.
Tolt now tracks payments from the customers your partners refer.
Good to know
For developers: the Chargebee integration guide in Tolt's API docs covers the same setup in more detail, including refunds and cancellations.
To record customers when they sign up, before they pay, see Track sign-ups as leads.
To check that everything works, see Test the integration.
Need a hand? Contact us via chat and we'll set up Chargebee with you.


