Skip to main content

Set up Chargebee with Tolt

Connect Chargebee so Tolt can track the customers and payments your partners refer.

Written by Nick

Connect Chargebee so Tolt can credit partners for the customers they refer. You add your Chargebee site and API key, add the tracking script to your site, pass each visitor's referral to Chargebee and add a webhook.

Connect Chargebee

  1. Go to Settings › Integrations, click Add integration and choose Chargebee.

  2. Under 1. Connect Chargebee, enter your Chargebee site, without https://, such as acme.chargebee.com.

    Chargebee setup page with the Chargebee site and API key fields
  3. In Chargebee, go to Settings › Configure Chargebee › API Keys and Webhooks and create a Full-Access key.

  4. Paste it into API key in Tolt.

Add the tracking script

Under 2. Add the tracking script, copy the script and paste it inside the <head> tag of every page of your website and app. It already includes your public key:

<script
async
src="https://files.tlt-cdn.com/v2/tlt.js"
data-tolt="YOUR_PUBLIC_KEY"
></script>

Use the Next.js or Google Tag Manager tab if your site uses them. On Webflow, Framer or WordPress, paste it into the site-wide head code.

Pass the referral to Chargebee

The tracking script stores each referred visitor's referral in window.tolt_referral. Store it on the Chargebee customer. Pick the tab under 3. Pass the referral to Chargebee that matches your checkout.

Drop-in checkout: in Chargebee, go to Settings › Configure Chargebee › Custom Fields and add a customer field with the API name cf_tolt_referral. Then set it on the cart when the buyer starts checkout:

function startCheckout() {
// Set by the tracking script; empty when the visitor wasn't referred
const referral = window.tolt_referral;
if (referral) {
Chargebee.getInstance().getCart().setCustomer({ cf_tolt_referral: referral });
}
// ...then open the checkout
}

API: send window.tolt_referral from the browser to your server, and add it as tolt_referral in meta_data when you create the customer:

const { customer } = await chargebee.customer.create({
email: "[email protected]",
meta_data: { tolt_referral: referral },
});

Add the webhook

  1. In Chargebee, go to Settings › Configure Chargebee › Webhooks and click Add Webhook.

  2. Paste the Webhook URL shown under 4. Add the webhook in Tolt, and set the API version to v2.

  3. Select these events:

    • Subscription Created

    • Subscription Cancelled

    • Subscription Deleted

    • Payment Succeeded

    • Payment Refunded

    • Coupon Deleted

  4. Switch on Exclude card information from webhook call and save the webhook.

Save the integration

  1. Optionally, under 5. Settings, switch on Exclude Chargebee tax to calculate commissions on the amount before tax.

  2. Click Save integration.

Tolt now tracks payments, refunds and cancellations from the customers your partners refer. The integration shows under Connected in Settings › Integrations.

Good to know

  • With Chargebee connected, Tolt records payments for you. Don't also send the same payments through Tolt's API, or commissions count twice.

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

  • For developers: the Chargebee integration guide covers the same setup, including refunds and cancellations.

  • Need a hand? Contact us via chat and we'll set up Chargebee with you.

Did this answer your question?