> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cello.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Chargebee Webhook Quickstart

> Learn how to integrate Cello if you are using Chargebee JS to create Chargebee customer and Chargebee Webhook to send Cello conversion events.

<Tip>
  This guide is **optimized for the typical freemium scenario with Chargebee**.

  Use this guide if you:

  * Create Chargebee customer on signup
  * Use Chargebee webhook to send Cello referral conversion events
</Tip>

# Step 1: Integrate the Referral Component

First, integrate Cello Referral Component into your web app to provide referrers with full referral experience.

Referral Component is integrated using one of our SDKs. For your web app, use Cello JS - our client-side SDK. You can install it by:

1. Adding a script tag to the `<head>` of your application
2. Generating a JWT token for user authentication
3. Booting the component with the provided token and user details

Follow this installation guide:

<CardGroup cols={2}>
  <Card title="Referral Component Quickstart" icon="js" horizontal href="https://docs.cello.so/referral-component/quickstart" />
</CardGroup>

You can also integrate Referral Component into your mobile applications:

<CardGroup cols={2}>
  <Card title="iOS SDK" icon="apple" horizontal href="https://docs.cello.so/sdk/mobile/ios" />

  <Card title="Android SDK" icon="android" horizontal href="https://docs.cello.so/sdk/mobile/android" />

  <Card title="React Native SDK" icon="react" horizontal href="https://docs.cello.so/sdk/mobile/react-native" />
</CardGroup>

# Step 2: Capture referral codes on landing page

Next, you will need to add [Cello attribution script](https://docs.cello.so/sdk/client-side/attribution-lib) to your referral landing page:

1. Setup a [landing page](https://docs.cello.so/docs/optimize-landing) for your referral links to redirect to
2. Install attribution script. Choose one of the following installation options best suited for your setup:

   <CardGroup cols={2}>
     <Card title="Embedded Script Tag" icon="code" horizontal href="https://docs.cello.so/sdk/client-side/embedded-script-tag" />

     <Card title="Google Tag Manager" icon="google" horizontal href="https://docs.cello.so/sdk/client-side/google-tag-manager" />
   </CardGroup>
3. Verify the installation

   <Check>
     To verify, follow these steps:

     1. Add `?productId=test` and `?ucc=test` to your website URL

        ```html theme={null}
         https://yourwebsite.com/?productId=test&ucc=test
        ```
     2. Make sure that these values are saved in the cookies as `cello-product-id` and `cello-referral`
     3. Navigate to your signup page and try to access the ucc using the `getUcc()` method from the browser console

        ```javascript theme={null}
        window.CelloAttribution('getUcc')
        ```

        This method should return a promise with value `test`

        ```javascript theme={null}
        Promise {<fulfilled>: 'test'}
        ```

     **If this check passes, the script is installed correctly.**
   </Check>

For capturing referral code in your mobile signup flow, follow this guide:

<CardGroup cols={2}>
  <Card title="Mobile signup flow" icon="mobile" horizontal href="https://docs.cello.so/attribution/for-mobile" />
</CardGroup>

# Step 3: Add Cello metadata or custom fields on Chargebee customer creation

To track a signup, you can pass the following metadata to Chargebee on customer creation.

<Note>
  You can also choose to use **Chargebee custom fields (CF\_)** to add referral data to the event. Learn more about custom fields in the [**Chargebee documentation**](https://www.chargebee.com/docs/billing/2.0/site-configuration/custom_fields)
</Note>

* `cello_ucc` - ucc, a referral code identifying the referrer. You can retrieve this code using [attribution script](https://docs.cello.so/sdk/client-side/attribution-lib) `getUcc ()` method, you have installed as a prerequisite to this guide.
* `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](https://docs.cello.so/sdk/client-side/cello-js), 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.

Modify customer data you send upon customer creation. Here is an example for a NodeJS App that does that with `meta_data`:

```javascript theme={null}
var chargebee = require("chargebee");

chargebee.configure({site : "getmoonly-v3-test", api_key : "test_jqXGuQLkBHUSR2PM0qgUV21W1VqSFJIU"});
chargebee.customer.create({
   first_name : "Bob", 
   last_name : "Bobsky", 
   //...
   // other customer fields
   //...
   meta_data: {
		cello_ucc: "hdz7afhs7",
		new_user_id: "xcsdad", // product user id of the new user
        new_user_organization_id: "123456"
			}
//   ..
// })
```

<Check>
  Now that the customer is created in Chargebee with Cello metadata, a `Customer Created` event will be sent with [Chargebee Webhook](https://docs.cello.so/integrations/webhooks/chargebee-webhook), which we will count as a signup event in Cello.
</Check>

# Step 4: Connect Chargebee Webhook to send signup and purchase events

To send Cello signup and purchase events, you will need to connect Chargebee Webhook to Cello.

Follow this guide to connect the webhook:

<CardGroup cols={2}>
  <Card
    title="Chargebee Webhook"
    icon={<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.1464 18.0024L35.9265 12.3313V0H23.5953L12.1464 18.0024Z" fill="#FF3300"/>
<path d="M0.36 17.7853C0.36 19.2605 0.539827 20.6924 0.879691 22.0664L12.1451 18.0017L0.786251 13.9024C0.509734 15.1512 0.36 16.4499 0.36 17.7819V17.7853Z" fill="#FF3300"/>
<path d="M4.54902 6.32317L12.1436 18.0031L15.6415 0.177188C11.2091 0.799913 7.3026 3.05771 4.54902 6.32317V6.32317Z" fill="#FF3300"/>
<path d="M12.1464 18.0008L35.9265 23.6686V35.9998H23.5953L12.1464 18.0008Z" fill="#FF3300"/>
<path d="M4.54902 29.6798L12.1436 17.9978L15.6415 35.8204C11.2091 35.1977 7.3026 32.9399 4.54902 29.6744L4.54902 29.6798Z" fill="#FF3300"/>
</svg>}
    href="/integrations/webhooks/chargebee-webhook"
  >
    Send events using Chargebee Webhook
  </Card>
</CardGroup>

<Check>
  **Congratulations!** You are done and now able to try out the full Cello referral experience 🎉
</Check>
