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

# Stripe Webhook Quickstart

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

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

  Use this guide if you:

  * Create Stripe customer on signup
  * Use Stripe 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 on Stripe customer creation

To track a signup, you can pass the following `metadata` to Stripe [Customer Object](https://docs.stripe.com/api/customers/object?api-version=2024-09-30.acacia#customer_object-metadata) on customer creation.

* `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 fields you send upon customer creation. Here is an example for a NodeJS App that does that:

```javascript theme={null}
const stripe = require('stripe')('sk_test_51KiCYYCSMQAUBF...');

const customer = await stripe.customers.create({
  description: 'New Stripe Customer',
   metadata: {
				cello_ucc: "hdz7afhs7",
				new_user_id: "xcsdad", // product user id of the new user
                new_user_organization_id: "123456" // organization id of the new user
			}
});
```

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

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

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

Follow this guide to connect the webhook:

<CardGroup cols={2}>
  <Card
    title="Stripe Webhook"
    icon={<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clipPath="url(https://mintlify.s3.us-west-1.amazonaws.com/cello/attribution/use-cases#clip0_19722_44991)">
<path d="M18 36C27.9411 36 36 27.9411 36 18C36 8.05888 27.9411 0 18 0C8.05888 0 0 8.05888 0 18C0 27.9411 8.05888 36 18 36Z" fill="#635BFF"/>
<path fillRule="evenodd" clipRule="evenodd" d="M16.596 13.995C16.596 13.149 17.289 12.816 18.441 12.816C20.097 12.816 22.185 13.32 23.841 14.211V9.09898C22.032 8.37898 20.25 8.09998 18.45 8.09998C14.031 8.09998 11.097 10.404 11.097 14.256C11.097 20.259 19.368 19.305 19.368 21.897C19.368 22.896 18.495 23.22 17.28 23.22C15.471 23.22 13.167 22.482 11.34 21.483V26.658C13.365 27.531 15.408 27.9 17.28 27.9C21.807 27.9 24.921 25.659 24.921 21.762C24.885 15.282 16.596 16.434 16.596 13.995Z" fill="white"/>
</g>
<defs>
<clipPath id="clip0_19722_44991">
<rect width="36" height="36" fill="white"/>
</clipPath>
</defs>
</svg>}
    href="https://docs.cello.so/integrations/webhooks/stripe-webhook"
  >
    Send events using Stripe Webhook
  </Card>
</CardGroup>

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