Chargebee Drop-In
You use Chargebee Drop-In 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: Create a custom field in Chargebee
Create a custom field in your Chargebee dashboard by going to Settings -> Configure Chargebee -> Custom Fields -> Customer -> Single line text
Give it a value of
Label: pushlap_affiliate_id
API Name: cf_pushlap_affiliate_id
Step 3: Send Affiliate ID Chargebee
Send the Push Lap Affiliate Id to Chargebee using the custom field (cf_pushlap_affiliate_id) you created in step 2.
Note: You need to have installed the chargebee.js dropin script on your site
The Push Lap Affiliate Id can be received from the script that was added in step 1. To access this ID, use window.affiliateId
.
Send the Push Lap Affiliate Id to Chargebee by creating a customer with that custom field value. Here's an example you can add to the bottom of your checkout page before the closing </body> tag:
<script>
var setupCb = function () {
if (typeof Chargebee === "undefined") return;
var cbInstance = Chargebee.getInstance();
var cart = cbInstance.getCart();
if (window.affiliateId) {
cart.setCustomer({
cf_pushlap_affiliate_id: window.affiliateId,
});
}
};
window.addEventListener("affiliate_id_ready", function (event) {
"complete" === document.readyState ||
("loading" !== document.readyState && !document.documentElement.doScroll)
? setupCb()
: document.addEventListener("DOMContentLoaded", setupCb);
});
</script>
Step 4: 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"