# Installing Cabin

<!-- **Available on:** every plan -->

Start by adding your domain on the [Domains](https://withcabin.com/settings/domains) page. Then follow the instructions below to add Cabin to your site.

The script is the same everywhere: one line, 2 KB, no configuration. Once it's live, visits show up in your dashboard within a few seconds.

It's also open source. You can read exactly what runs on your visitors' browsers at [github.com/withcabin/hello.js](https://github.com/withcabin/hello.js), and the built file in that repository is byte-for-byte the one the CDN serves, so there's nothing to take on trust.

## Basic Installation

Place the following code before your closing `</body>` tag.

```html
<script async defer src="https://scripts.withcabin.com/hello.js"></script>
```

## WordPress

1.  Install the [Insert Headers and Footers](https://wordpress.org/plugins/insert-headers-and-footers/#installation) plugin.
2.  Go to **Settings** > **Insert Headers and Footers** menu.
3.  Paste the code below into the **Footer scripts**:
    ```html
    <script async defer src="https://scripts.withcabin.com/hello.js"></script>
    ```
4.  Click **Save**.

## Shopify

> [!NOTE]
> This requires access to your Shopify theme code.

1. From your Shopify admin, go to **Online Store** > **Themes**.
2. Find the theme you want to edit and click **Actions** > **Edit code**.
3. In the Layout directory, click on `theme.liquid`.
4. Find the closing `</body>` tag and paste the following code just before it:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
5. Click **Save**.

## WooCommerce

1. Install and activate the [Code Snippets](https://wordpress.org/plugins/code-snippets/) plugin.
2. Go to **Snippets** > **Add New**.
3. Give your snippet a title like "Cabin Analytics".
4. Paste the following code:
   ```php
   function add_cabin_analytics() {
       echo '<script async defer src="https://scripts.withcabin.com/hello.js"></script>';
   }
   add_action('wp_footer', 'add_cabin_analytics');
   ```
5. Set the snippet to run on the "Frontend" only.
6. Click **Save Changes and Activate**.

Alternatively, you can follow the WordPress instructions above using the Insert Headers and Footers plugin.

## Squarespace

> [!NOTE]
> Only available on Squarespace's Business or Commerce plans.


1. Click **Settings**, click **Advanced** and then click **Code Injection**
2. Add the following code to the **Footer**:
   ```html
    <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
3. Click **Save** at the top of the page.

More details at [Squarespace](https://support.squarespace.com/hc/en-us/articles/205815908-Using-Code-Injection)

## Wix

> [!NOTE]
> Only available on a paid Wix plan.

1.  Click **Settings** in your site's dashboard.
2.  Click the **Tracking & Analytics** tab under **Advanced Settings**.
3.  Click **+ New Tool** and select **Custom** from the dropdown.
4.  Paste in the code from below:
    ```html
    <script async defer src="https://scripts.withcabin.com/hello.js"></script>
    ```
5.  Select the relevant domain. _Note: This option will appear only if you have multiple domains_.
6.  Enter a name for your custom code. E.g. _Cabin Script_
7.  Add Code to Pages: Choose **All Pages** and **Load code once**.
8.  Place Code in: Choose **Body - end**.
9.  Click **Apply**.

More details on [Wix](https://support.wix.com/en/article/embedding-custom-code-to-your-site)

## Next.js

Create or edit the `app/layout.js` (or `app/layout.tsx`) file and import the script in your RootLayout component:

```jsx
import Script from 'next/script'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head>
        <Script
          src="https://scripts.withcabin.com/hello.js"
          strategy="afterInteractive"
        />
      </head>
      <body>
        {children}
      </body>
    </html>
  )
}
```

More details on [Next.js Script component](https://nextjs.org/docs/app/building-your-application/optimizing/scripts).

## Ghost

1.  Go to your **Ghost Admin settings**.
2.  Click on **Code Injection** in the sidebar menu.
3.  Paste the tracking code below into the **Foot** section: 
    ```html
    <script async defer src="https://scripts.withcabin.com/hello.js"></script>
    ```
4.  Click **Save**.  

More details on [Ghost](https://ghost.org/help/post-settings/#code-injection).

## Webflow

> [!NOTE]
> Only available for paid Webflow accounts.

1. Go to your **Project settings** (gear icon in the left sidebar).
2. Select **Custom code** in the tabs menu.
3. Paste the tracking code below into the **Footer Code** section:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
4. Click **Save Changes**.
5. Click **Publish** to make your changes live.

More details on [Webflow custom code](https://help.webflow.com/hc/en-us/articles/33961357265299-Custom-code-in-head-and-body-tags).

## Nuxt
1. Edit your `nuxt.config.js` file
2. Add the script to `app.head`:
   ```js
   export default defineNuxtConfig({
     app: {
       head: {
         script: [
           {
             src: 'https://scripts.withcabin.com/hello.js',
             defer: true,
             async: true
           }
         ]
       }
     }
   })
   ```

More details on [Nuxt head management](https://nuxt.com/docs/getting-started/seo-meta).

## Svelte/SvelteKit

1. Edit your `src/app.html` file
2. Add the script before the closing `</body>` tag:
   ```html
   <!DOCTYPE html>
   <html lang="en">
     <head>
       <meta charset="utf-8" />
       <meta name="viewport" content="width=device-width" />
       %sveltekit.head%
     </head>
     <body data-sveltekit-preload-data="hover">
       <div style="display: contents">%sveltekit.body%</div>
       <script async defer src="https://scripts.withcabin.com/hello.js"></script>
     </body>
   </html>
   ```

More details on [SvelteKit app.html](https://kit.svelte.dev/docs/project-structure#project-files-app-html).

## Gatsby

1. Install the Gatsby Script API:
   ```bash
   npm install gatsby-script
   ```

2. Edit your layout component (typically in `src/components/layout.js`):
   ```jsx
   import React from "react"
   import { Script } from "gatsby"

   export default function Layout({ children }) {
     return (
       <>
         {children}
         <Script
           src="https://scripts.withcabin.com/hello.js"
           strategy="postHydrate"
           async
           defer
         />
       </>
     )
   }
   ```

More details on [Gatsby Script API](https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-script/).

## Hugo

1. Create or edit the file `layouts/partials/footer.html` in your Hugo project.
2. Add the following code:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
3. Make sure this partial is included in your site's main layout.

Alternatively, you can add it directly to `layouts/_default/baseof.html` before the closing `</body>` tag.

More details on [Hugo Templates](https://gohugo.io/templates/introduction/).

## Astro

1. Edit your main layout file (typically in `src/layouts/Layout.astro`):
   
```html
<html lang="en">
    <head>
    <!-- Your head content -->
    </head>
    <body>
    <slot />
    <script async defer src="https://scripts.withcabin.com/hello.js"></script>
    </body>
</html>
```

More details on [Astro Layouts](https://docs.astro.build/en/core-concepts/layouts/).

## Framer

> [!NOTE]
> This requires a paid Framer plan that allows custom code insertion.

1. Open your Framer project.
2. Click on the **Settings** icon in the left sidebar.
3. Select the **General** tab.
4. Scroll down to **Custom Code**.
5. Paste the following code in the **Before `</body>` tag** section:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
6. Click **Save**.

## Bubble

1. Go to your Bubble app's dashboard.
2. Click on **Settings** in the left sidebar.
3. Navigate to the **SEO/metatags** tab.
4. Scroll down to **Advanced settings**.
5. Find the **Script in the body** section and paste the following code:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
6. Click **Save**.

More details on [Bubble's SEO/metatags settings](https://manual.bubble.io/core-resources/application-settings/seo-metatags#script-meta-tags-in-header).

## Carrd

> [!NOTE]
> This requires a Carrd Pro Standard plan or higher.

1. While editing your Carrd site, click on the **+** button (Add Element) in the top bar.
2. Select **Embed**.
3. Set **Type** to **Code**.
4. Paste the following code:
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
5. (Optional) Set **Label** to something descriptive like "Cabin Analytics".
6. For **Style**, select **Hidden** and choose **Body End** for placement.
7. Click **Add**.
8. Click **Publish** to make your changes live.

More details on [Carrd Custom Code Embedding](https://carrd.co/docs/building/embedding-custom-code).

## Webnode

> [!NOTE]
> This requires a Webnode Premium plan (for projects created after June 26, 2023).

1. In your Webnode editor, position your mouse in a section where you want to add the code.
2. Click the **plus button** to add new content.
3. In the content bubble, click the circle for more options, then click on **HTML**.
4. Paste the following code:   
   ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
5. Note that you will only be able to see the HTML added in the published version of your website, not directly in the editor.
6. Click **Publish** to make your changes live.

More details on [Webnode HTML code insertion](https://www.webnode.com/support/add-html-code/).

## Google Tag Manager

> [!WARNING]
> While this method works, it's not recommended for privacy-focused analytics. Using Google Tag Manager sends data to Google servers before loading Cabin, which defeats some of Cabin's privacy benefits. Consider direct installation when possible.

1. Log in to your [Google Tag Manager](https://tagmanager.google.com/) account.
2. Select your container.
3. Click on **Tags** in the left sidebar.
4. Click **New** to create a new tag.
5. Click on **Tag Configuration** and select **Custom HTML**.
6. Paste the following code:   
    ```html
   <script async defer src="https://scripts.withcabin.com/hello.js"></script>
   ```
7. Click on **Triggering** and select a trigger (typically "All Pages").
8. Name your tag (e.g., "Cabin Analytics") and click **Save**.
9. Click **Submit** to publish your changes.

More details on [Google Tag Manager](https://support.google.com/tagmanager/answer/6103696).

---

## Checking it works

Open your site, then open your Cabin dashboard: your own visit should appear right away. If nothing shows up, check that the script tag is in the published version of the page (view source and search for `hello.js`), and that an ad-blocker isn't blocking it. [Custom domains](https://docs.withcabin.com/bypass-ad-blockers.md) fix that for good.

You can also ask an AI assistant to check it for you with [MCP](https://docs.withcabin.com/mcp.md): "is Cabin installed correctly on example.com?"

If you need more help installing Cabin, please contact [hello@withcabin.com](mailto:hello@withcabin.com).
