Bolt
Step-by-step guide to add OnyxMetric cookieless analytics to your Bolt app and start tracking visitors
Bolt has no settings field for custom head code, so the tag goes into the app's HTML head as a code change. Prompt Bolt to add it, or switch to Code view and paste it into the root file.
Copy your tracking snippet
In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>YOUR_SITE_ID is the numeric ID of your site.
Add the snippet to Bolt
Paste this into the chat:
Add this script tag to the <head> of every page and keep all existing head tags:
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>Review the change: the tag belongs in the document head, not inside a component.
Click the Code Preview icon (<>) at the top center to switch to Code view, then open the file that owns the <head>:
- Vite projects (React, Vue, Svelte):
index.htmlat the project root. - Next.js projects:
app/layout.tsx, usingnext/scriptas in the Next.js guide. - Anything else: ask Bolt which file renders the HTML head, then edit that one.
For Vite, paste the snippet before </head>:
<head>
<meta charset="UTF-8" />
<title>My app</title>
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>
</head>Save the file.
Then open the Publish menu and click Publish (first time) or Update (already live). In-app navigation is tracked as pageviews automatically.
Check that it works
Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.
If nothing arrives:
- View the page source and search for
script.js?siteId=to confirm the tag is present. - In the browser's Network tab, check that
script.jsreturns200and that requests go to/api/track. - Turn off ad blockers, or proxy the script through your own domain.
- Read script troubleshooting for other causes.
Troubleshooting
- Published site unchanged: edits do not reach the live site until you click Update in the Publish menu.
- Bolt removed the tag: later prompts can regenerate
index.htmlor the layout. Lock the file in the Files list, or add a line to the project's Knowledge telling Bolt to keep the OnyxMetric script. - Expo (mobile) projects: a script tag only runs in the web build. For the native app, use the JavaScript SDK.
- Numbers differ from Bolt's Analytics: Bolt's built-in counts include crawlers and bots, which OnyxMetric filters out.
Next steps
- Track custom events such as signups, purchases, and clicks.
- Identify users to tie sessions to accounts.
- Proxy the script through your own domain to get past ad blockers.
- Script attributes let you skip or mask URLs and tag events.