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

# Embedded Script Tag

> Learn how to add Cello attribution script to your website

Attribution script helps you to capture referral code on your landing pages and make it available at signup to attribute referral conversions to the right referrers. In addition, it helps you to personalize messages for referees on the landing page, get discount information and detect potential fraud and abuse of your referral program.

**Script Loading Context:** The attribution script loads asynchronously and methods become available shortly after page load. All attribution methods use the unified `window.CelloAttribution("methodName")` syntax.

# Adding the script

You can add attribution script to your website like any other third party JavaScript code by inserting the following code snippet into the `<head>` tag of **each page** on your website.

<Note>
  Make sure to use `type="module"` and `async` html params in the script tag
</Note>

<Tabs>
  <Tab title="Sandbox URL">
    ```javascript theme={null}
    <script type="module" src="https://assets.sandbox.cello.so/attribution/latest/cello-attribution.js" async></script>
    ```
  </Tab>

  <Tab title="Production URL">
    ```javascript theme={null}
    <script type="module" src="https://assets.cello.so/attribution/latest/cello-attribution.js" async></script>
    ```
  </Tab>
</Tabs>

# Verifying the installation

Now that you have added the attribution script to your website, make sure that the `ucc` is available on the signup page. To verify, follow these steps:

## Step 1: Test with URL parameters

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

```html theme={null}
https://yourwebsite.com/?productId=test&ucc=test
```

## Step 2: Check cookie storage

Open browser developer tools (F12) and verify these values are saved in cookies:

* `cello-product-id` should contain `test`
* `cello-referral` should contain `test`

## Step 3: Test method access

Navigate to your signup page and test the attribution methods from the browser console:

```javascript theme={null}
// Wait for script to load if needed
setTimeout(async () => {
  try {
    const ucc = await window.CelloAttribution('getUcc');
    console.log('UCC test result:', ucc); // Should return 'test'
    
    // Test other methods
    const referrerName = await window.CelloAttribution('getReferrerName');
    const campaignConfig = await window.CelloAttribution('getCampaignConfig');
    
    console.log('Attribution methods working:', {
      ucc,
      referrerName,
      campaignConfig
    });
  } catch (error) {
    console.error('Attribution test failed:', error);
  }
}, 2000);
```

Expected result:

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

## Troubleshooting Installation Issues

### Script not loading

```javascript theme={null}
// Check if script loaded
if (typeof window.CelloAttribution !== 'function') {
  console.error('Attribution script failed to load');
  // Check network tab for loading errors
  // Verify script URL is accessible
}
```

### Methods return undefined

* Wait longer for script initialization (try 3-5 seconds)
* Check browser console for JavaScript errors
* Verify script tag has `type="module"` and `async` attributes
* Ensure no ad blockers are interfering

### Cookie issues

* Check if cookies are enabled in browser
* Verify no GDPR/cookie consent is blocking storage
* Test in incognito mode to rule out extensions

<Icon icon="check" color="#027A48" size={16} /> **Installation successful** if methods return expected values and cookies are stored properly.

<Icon icon="warning" color="#D92D20" size={16} /> **Need help?** Check the [troubleshooting guide](/sdk/client-side/attribution-js-usage#troubleshooting) for common issues and solutions.
