Chargebee Quickstart

This Quickstart will walk you through how to get Cello integrated in 4 easy steps, if you are using Chargebee as the payment gateway.

By the end of this guide, you'll have Cello implemented end-to-end including:

Lets get started 🚀

0. Sign in to Cello

Go to Cello Portal and login to access your product dashboard.

1. Add Referral component to your app

Before you begin, you need:

  • Product ID (productId) - Identifier of the product your users will refer. You can access it in you product dashboard on Access Keys page.
  • Product User ID (productUserId) - The unique identifier for your users. ❗It is important that this ID is unique per user, rather than organisation.
  • Product Secret (PRODUCT_SECRET) - Provided in section 4 of your onboarding workspace

Include Cello JS library

To add Cello Referral Component from CDN, use the following script in the head tag of your index.html

Javascript
Copy

Add user authentication with JWT token

Generate a JWT token

Never generate a token or store your secret on the client side

Javascript
Copy

Initialize the Referral component

Now, we can initialize the Referral component with the JWT token we just generated

Javascript
Copy

Now, reload your application and you should see the Cello button appear. You can now try out the referrer experience.

💡 Don't want to use the Cello button? Use custom launcher to open Referral component from a menu item or a button in your app.

Let's move on to new user experience and referral tracking 👉

2. Track attributions on your landing page

You will need to configure which page the referred user lands on when clicking on the invite link, shared with them by the referrer. The easiest option is to use your Home page as landing page with a standard New user banner, to show the offer to the new user.

💡 Learn about other options for landing pages in this guide

To configure it:

  1. Go to Cello Portal New User experience page.
  2. Choose "Custom landing page" and add your Home page URL.
  3. In the "Personalized message" tab, check "Show new user banner" and other settings and save.
  4. Add Attribution library to your Home page by including the following script in the <head> tag to track attributions and show New user banner.
Javascript
Copy

Now, if you visit an invite link of any referrer, you will be redirected to your Home page and will see the New user banner.

3. Track signups with Chargebee

When a signup finally happens, you need to make sure that a ucc code, identifying the referrer, is saved to the new user record and passed to Chargebee upon customer creation.

Access Ucc code during signup

Ucc is present in the URL of your Home page when a new user is redirected to it from the invite link and in the cookies, added by the Attribution library.

Copy

To access the ucc during signup, you can use the Attribution library JS method getUcc().

Here is how to do it:

  • Add the following javascript code before any of the calls to the library to avoid race conditions.
Javascript
Copy
Javascript
Copy

Add metadata to Chargebee customer

Chargebee webhook supports custom fields (CF). You can choose to use metadata or custom fields to add referral data to the event. Learn more about custom fields in the Chargebee documentation

Next, at the point when you create a customer in Chargebee, make sure that you add the following metadata to the Chargebee customer:

  • cello_ucc - ucc, a referral code identifying the referrer
  • new_user_id - a unique user ID in your system, identifying the new user who just signed up. This should be the same ID (productUserId) you will use to boot the Referral component, when this user logs into your app
  • new_user_organization_id (optional) - add this, if your referrers can refer an organization rather then a single user and you want to reward based on that.

Below is an example for a NodeJS app, illustrating how to include during customer creation.

Javascript
Copy

Now, the final step - sending signup and transaction data to Cello 👉

4. Send signup and transaction events to Cello with Chargebee Webhook

You will add a Webhook to your Chargebee configuration to connect Chargebee and Cello. This can be done in both test and production environments separately.

To set up:

  1. Log in to Cello Portal and go to Webhooks to get your endpoint URL and authentication details.

  2. Log in to your Chargebee dashboard.

  3. From the sidebar, select Settings > Configure Chargebee and click on Webhooks.

  4. Click on "+ Add Webhook" and fill out the Endpoint URL provided based on the environment.

  5. Select the events you want to send under "Events to Send." Select the events

    1. customer_created, customer_changed, customer_deleted
    2. subscription_created, subscription_changed, subscription_deleted
    3. payment_succeeded, p ayment_refunded
  6. To secure the webhook, select Protect webhook URL with basic authentication and add the username and secret provided in the Cello Portal.

  7. Be sure to select Exclude card Information from webhook call

  8. Finally click Create to enable the webhook

Endpoint created 🎉

Congratulations! You are done and now able to try out the full Cello referral experience 🎉

Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard