# Fibr Script

The Fibr Script is what connects your website to Fibr. It's a small code snippet that you add once, and it enables everything Fibr does: experiments, personalization, tracking, and real-time optimization.

Without it, Fibr can't see your visitors or deliver dynamic experiences. With it, your site can adapt to every campaign, audience, and condition automatically.

***

#### **How It Works**

When someone visits your site, the Fibr Script runs instantly and does three things:

1. **Identifies the visitor.** It checks who they are based on your configured rules: which ad they clicked, what audience segment they belong to, whether they're new or returning, their location, and more.
2. **Finds the right experience.** If the visitor matches any of your active experiments or personalization campaigns, Fibr selects the appropriate variant.
3. **Delivers it immediately.** The experience loads client-side during page render. Your visitor sees the personalized version without any flicker, delay, or visible swap.

This all happens in milliseconds. Your site adapts dynamically without requiring any additional deployments or engineering work.

***

#### **Installation Options**

Choose the method that fits your setup:

<table data-view="cards"><thead><tr><th></th><th data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td>Add Fibr SDK to your Website</td><td><a href="fibr-script/configure-fibr-script-to-your-website">configure-fibr-script-to-your-website</a></td><td><a href="https://3335504681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80aS5Lqrk8qDoq5OTbgm%2Fuploads%2FWj8rZSYwsxis5RRM3GEw%2Fwebsite-icon-www-illustration-sign-site-symbol-internet-logo-vector.jpg?alt=media&#x26;token=05578cbc-8d09-455f-9eb9-e201b52991b8">website-icon-www-illustration-sign-site-symbol-internet-logo-vector.jpg</a></td></tr><tr><td>Connect with Shopify Store </td><td><a href="fibr-script/configuring-the-fibr-script-for-your-shopify-store">configuring-the-fibr-script-for-your-shopify-store</a></td><td><a href="https://3335504681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F80aS5Lqrk8qDoq5OTbgm%2Fuploads%2FRlpfFEX5BbSD5Myi3tUo%2Fshopify-logo-png_seeklogo-267188.png?alt=media&#x26;token=257804db-113a-4c52-b8d6-34a1bb35c005">shopify-logo-png_seeklogo-267188.png</a></td></tr></tbody></table>

***

#### **Best Practices for Installation**

* **Place it in the `<head>` tag** The script needs to load early in the page lifecycle to work correctly. Add it inside the `<head>` section of your HTML.
* **Put it above other scripts** Position the Fibr Script at the top of your `<head>`, before analytics tags, tracking pixels, or other third-party scripts. This ensures Fibr initializes first and can deliver the right experience before anything else runs.
* **Avoid script conflicts** If you have multiple scripts that modify page content or load asynchronously, they can interfere with Fibr's timing. Keep your `<head>` clean and test after adding new scripts.
* **Whitelist all your domains** In your Fibr workspace, add every domain and subdomain where the script will run. You can apply it site-wide or restrict it to specific URLs if you want tighter control over where campaigns run.
* **Validate before launching campaigns** Before you create experiments or personalization campaigns, confirm the script is working:
  * Go to **Settings → Setup → Validate** in your Fibr Dashboard
  * Enter your URL and click **Check**
  * You'll see a confirmation if the script is firing correctly

This takes 30 seconds and saves you from troubleshooting later.

***

#### What's Next?

Once the script is installed and validated:

1. [**Connect Google Analytics(GA4)**](https://support.fibr.ai/integrations/integrate-google-analytics-ga4) to pull performance data into Fibr
2. [**Link your ad accounts**](https://support.fibr.ai/integrations/integrate-google-ads) to enable ad personalization
3. [**Create your first experiment**](https://support.fibr.ai/hypothesis-and-experimentation/how-to-launch-new-experiments-on-fibr-ai) with Fibr AI
