Chargebee API
You use Chargebee API for Checkout or Subscriptions
Step 1: Tracking Clicks
Insert the following script in your website's <head>
tag to start tracking clicks:
Normal Method
<script
src="https://pushlapgrowth.com/affiliate-tracker.js"
data-affiliate
data-program-id="YOUR_AFFILIATE_PROGRAM_ID"
async>
</script>
Using Google Tag Manager
<script>
var pushLap = document.createElement('script');
pushLap.src = "https://pushlapgrowth.com/affiliate-tracker.js";
pushLap.setAttribute('data-affiliate', '');
pushLap.setAttribute('data-program-id', 'YOUR_AFFILIATE_PROGRAM_ID');
document.head.appendChild(pushLap);
</script>
Step 2: Send Affiliate ID Chargebee
Send the Push Lap Affiliate Id to Chargebee using meta_data for a customer.
The Push Lap Affiliate Id can be received from the script that was added in step 1. To access this ID, use window.affiliateId
on your frontend code .
Send the Push Lap Affiliate Id to Chargebee by creating a customer. Here's an example:
import { ChargeBee, _customer } from 'chargebee-typescript';
var chargebee = new ChargeBee();
chargebee.configure({site: "{site}", api_key: "{site_api_key}"});
chargebee.customer.create({
first_name: "John",
last_name: "Doe",
email: "john@test.com",
locale: "fr-CA",
billing_address: {
first_name: "John",
last_name: "Doe",
line1: "PO Box 9999",
city: "Walnut",
state: "California",
zip: "91789",
country: "US"
},
meta_data: {
pushlap_affiliate_id: "AFFILIATEL_ID_RECEIVED_FROM_window.affiliateId"
}
}).request(function(error,result) {
if(error){
//handle error
console.log(error);
}else{
var customer: typeof chargebee.customer = result.customer;
var card: typeof chargebee.card = result.card;
}
});
Step 3: Create and setup Webhook to track sales
Create a new endpoint for Chargebee to send events to. You can do this in your Chargebee dashboard by going to Settings -> Configure Chargebee -> Webhooks -> Add Webhook
Webhook Name: Push Lap Growth Integration
Webhook Endpoint: https://www.pushlapgrowth.com/api/webhooks/chargebee?program_id=fc96bb84-278c-4b44-bcd1-9ec9fb816505
API Version: Version 2
Choose the following events:
Subscription Created
Subscription Started
Subscription Activated
Subscription Cancelled
Subscription Deleted
Payment Succeeded
Payment Refunded
Enable the option: "Exclude card information from webhook call"