> For the complete documentation index, see [llms.txt](https://docs.intelligems.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.intelligems.io/getting-started/adding-intelligems-script-to-your-theme.md).

# Adding Intelligems Script to your Theme

### **Introduction**

Adding the Intelligems script to your site is the most important step to getting started with Intelligems. It's the only integration step you need for Content, Merchandising and Shipping experiences, and it's the first step for Pricing, Checkout and Post-purchase. There are two options below for adding the Intelligems script to your site.

{% hint style="warning" %}
**The script is per theme.** Whichever option you use, Intelligems has to be live on every theme you want to run an experience on. A brand-new theme starts with the app embed switched off, so a theme change experience needs it enabled on the new theme as well as your current one, and a preview on a draft theme won't load until it's on.
{% endhint %}

### **Option 1: Use the App Embed Block**

{% hint style="success" %}
This is the easiest installation method that works for most stores!
{% endhint %}

The fastest way to add Intelligems JavaScript to your theme is to enable it in the "Customize" section of your theme editor. You can do so by logging into your Shopify Admin, and navigating to Sales Channels > Online Store > Live theme - "Edit Theme" > App Embeds. Search "Intelligems", make sure it is toggled on, and click "Save" in the top right.

This will load Intelligems in a fashion that works optimally for performance and A/B testing on most stores. If for any reason you encounter performance concerns, see our docs on [performance optimization](https://docs.intelligems.io/performance-optimization/optimizing-your-price-test-integration).

Here's a video walking through those steps as well:

{% embed url="<https://www.loom.com/share/c147efbbbe064565b3948d824c049550>" %}

{% hint style="warning" %}
For any **password protected store**, we will not be able to automatically detect the script, so you will continue to get an error message in the app regarding the script not being in your theme.
{% endhint %}

### **Option 2: Add to Your Theme Code**

{% hint style="danger" %}
This will need to be manually removed if you uninstall Intelligems.
{% endhint %}

In Intelligems, go to **Admin Settings** and find the **Theme script** card. Click **Copy** and your unique Intelligems script is on your clipboard. The **Install method** line above the button tells you which method we're currently detecting on your store.

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

Now head over to your Shopify account, and paste the Intelligems Script as a source into the `<head>` of each of these files:

* theme.liquid
* any other theme.\*.liquid files (e.g., theme.gempages.liquid if you have this file)

Here's a video walking through those steps as well:

{% embed url="<https://www.loom.com/share/25908292b3104387923cb198dfaf8ef9>" %}

{% hint style="info" %}
**Pick one method.** If you hardcoded the script during an earlier install and have since turned on the app embed, remove the hardcoded copy so Intelligems only loads once.
{% endhint %}

The script format changed in December 2024. If you're still on the older one, the app flags it, and you'll want to [Update the Intelligems Script](https://docs.intelligems.io/getting-started/updating-the-intelligems-script).

{% hint style="info" %}
**Theme changes and the preview bar.** On Checkout Extensibility there's nothing extra to do. Checkout isn't part of your theme, so the theme preview bar can't appear there. If your store still has `checkout.liquid`, [reach out to support](https://intelligems.portal.usepylon.com/forms/intelligems-support-request) and we'll sort the preview bar out with you.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.intelligems.io/getting-started/adding-intelligems-script-to-your-theme.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
