# Install on Bolt

> Add MetricRaven to a Bolt.new project by prompting Bolt or editing the code, then publish.

Source: https://metricraven.com/docs/install-bolt  
Markdown: https://metricraven.com/docs/install-bolt.md  
Section: Installation guides

Ask Bolt to add the tag, or paste it yourself in the code view, then publish the project.

## Ask Bolt

1. **Send this prompt in the chat**

   Replace `YOUR_SITE_ID` with the public site ID from your site's **Settings → Install** card. The site ID is public and safe in browser code; never put your secret key in a page.

   ```text title="Prompt"
   Add this analytics script to every page of the app. Load it once for the whole app,
   in index.html or the root layout (with next/script in a Next.js app), never from a single
   page or component. Keep the src and data-site-id attributes exactly as written:

   <script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID"></script>
   ```

2. **Publish**

   Publish the project, then open the published URL. The in-editor preview doesn't count.

## Or edit the code

1. **Open the code view**

   Choose the **<>** code icon at the top of the editor and pick the file from the file tree. Code editing isn't available on mobile, and is read-only in Safari.

2. **Paste the tag into the page head**

   For a Vite project, that's `index.html`, before `</head>`. For a Next.js project, follow the [Next.js](https://metricraven.com/docs/install-nextjs) guide.

   ```html title="index.html"
   <script
     defer
     src="https://metricraven.com/js/script.js"
     data-site-id="YOUR_SITE_ID"
   ></script>
   ```

3. **Save and publish**

   Save the file and publish again.

> **Verify it works**
>
> Open your live website in a normal browser window (not an automated or embedded one). In the browser's Network panel, look for `script.js` and then a request to `/api/v1/collect` whose response contains `ok: true`. Open your site's **Traffic** tab and choose **Refresh**; the selected dates must include your visit.
>
> Nothing showing? See [Troubleshooting](https://metricraven.com/docs/troubleshooting).

## Notes

- Add the address your project is published on to your site's **Settings → General → Site** domains: a `*.bolt.host` address with Bolt hosting, a `*.netlify.app` address if you publish through Netlify, or your custom domain. Otherwise requests are refused with `domain_not_allowed`.
- AI edits can drift. After each publish, open your live app, view the page source and check the tag is still in `<head>` with its `data-site-id` unchanged.
- Click between a few pages and check the Network panel shows one `/api/v1/collect` pageview per navigation. Two per click means the tag is loaded twice.

Optional script attributes are listed in [Install & verify](https://metricraven.com/docs/install). To exclude your own visits, see [Exclude your visits](https://metricraven.com/docs/exclude-visits).
