# Sitewide JS

**Sitewide JS** allows you to run custom JavaScript across every page where the CustomFit.ai code snippet is installed. It acts as a centralized scripting layer that applies globally, rather than being tied to a specific experience.

The script executes **before any experience changes are applied**, ensuring that your global logic runs first. This makes it especially useful for preparing data, setting shared conditions, defining reusable functionality, or establishing variables that experiences can depend on.

Unlike experience-level scripts that are scoped to individual campaigns, Sitewide JS applies consistently across your website wherever CustomFit.ai is active. It helps maintain uniform behavior, reduces duplication, and gives you greater control over how your personalization and experimentation framework operates at a foundational level.

Sitewide JS runs **only on live experiences**, meaning it will not execute while experiences are powered off.

### Where to Find Sitewide JS

To configure Sitewide JS in CustomFit.ai, follow these steps:

1. Log in to your **CustomFit.ai Dashboard**.
2. From the left-hand sidebar, click on **Settings** and then select **CustomFit Setup**.
3. Inside the setup section, navigate to the **Sitewide JS** tab.
4. Enter your JavaScript code in the provided editor.
5. Save and publish your changes to apply them to live experiences.

<figure><img src="/files/DWAiFKqpfPM5a5mGZMzg" alt=""><figcaption></figcaption></figure>

#### Important Considerations

* Changes apply globally once published.
* Scripts execute only when experiences are live.
* Since it runs before experiences, avoid conflicts with later modifications.
* Keep logic optimized to prevent unnecessary overhead across pages.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.customfit.ai/sitewide-js.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
