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

# Custom script

> Add your own JavaScript to every page of your community site's custom domain.

A custom script is JavaScript that runs first on every page of your community site's custom domain, before the rest of the page loads. Use it for tools that need to load early, such as a cookie consent banner or a chat widget.

Add it in Studio under **[Site > Custom script](https://studio.tightknit.ai/-/website/custom-script)**.

> [!WARNING]
>
> Custom scripts only run on a [custom domain](https://docs.tightknit.ai/community-site/custom-domain.md), such as `community.your-domain.com`. They never run on a `.tightknit.community` subdomain. If your site doesn't have a custom domain, your script will not run.

## Requirements

* Your community site uses a [custom domain](https://docs.tightknit.ai/community-site/custom-domain.md). Tightknit sets up custom domains for you: [contact support](https://docs.tightknit.ai/support/contact.md) to add one.
* Your plan includes custom scripts.

## Add a script

**1. Paste your code**

In Studio, go to **[Site > Custom script](https://studio.tightknit.ai/-/website/custom-script)** and paste your JavaScript into **Head Script**. Paste only the code, without `<script>` tags.

If your vendor gives you a `<script src="…">` tag, load the file from JavaScript instead. Copy the tag's `src` URL, and add one `setAttribute` line for each other attribute on the tag:

```js theme={null}
var s = document.createElement("script");
s.src = "https://cdn.vendor.com/banner.js";
s.async = true;
s.setAttribute("data-domain-script", "0190-acme");
document.head.appendChild(s);
```

**2. Publish**

Select **Publish script** and confirm. The script goes live on every page of your custom domain, for every visitor and member, within a few minutes.

**3. Check it on your custom domain**

Open your site on its custom domain and confirm the script runs, for example that your cookie banner appears.

Studio refuses a script that has `<script>` tags, that doesn't parse as JavaScript, or that is longer than 65,536 characters, and says why under the field.

A script can read and change anything on the page, for every visitor and signed-in member. Only add code from a source you trust.

## Change or remove a script

Edit the code in **Head Script** and select **Publish script** to replace it. To remove it, select **Remove script**. Either change reaches your site within a few minutes.

## Troubleshooting

**The script doesn't run.** Check that you're visiting your site on its custom domain. If your site has no custom domain, custom scripts don't run anywhere: [contact support](https://docs.tightknit.ai/support/contact.md) to set one up.

**The script runs for some visitors but not others.** Changes can take a few minutes to reach every visitor. If it still doesn't run, check your browser's developer console for errors from the script itself.


## Related topics

- [Domain and URL](https://docs.tightknit.ai/community-site/custom-domain.md)
- [Custom email domain DNS setup](https://docs.tightknit.ai/guides/custom-email-domain.md)
- [MCP server](https://docs.tightknit.ai/integrations/mcp.md)
- [Set up Auth0 SSO](https://docs.tightknit.ai/guides/sso-auth0.md)
- [Journeys](https://docs.tightknit.ai/gamification/journeys.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.