Documentation menuAI app builders: Bolt

AI app builders

Add Loogika to Bolt

The Loogika tag goes into the HTML head of your Bolt app as a code change, because Bolt offers no settings field for custom head code. You either ask Bolt to add it in the chat or paste it yourself in Code view. Publish the project again afterwards.

Last updated .

What do you need before you start?

Copy your script tag from Site Settings in the Loogika dashboard, under the Tracking Script tab. The copied tag carries your 12-character site ID in place of YOUR_SITE_ID:

<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>

The Analytics setting of a Bolt project is something else. It shows traffic for published sites and has no place for a script.

How do you ask Bolt to add the Loogika tag?

Paste a prompt like the one below into the chat, with your own tag in it:

Add this script tag to the <head> of every page and keep all existing head tags:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>

Check Bolt's edit before you continue. The tag belongs in the document head and not in a component. A tag inside a component can load after the first page has rendered, and the first pageview is then lost.

How do you add the tag yourself in Code view?

The Code Preview icon at the top centre switches Bolt to Code view. From there, open the file that holds the head for the framework Bolt chose.

Project typeFile to edit
Vite with React, Vue or SvelteThe index.html file in the root of the project
Next.jsapp/layout.tsx. The Next.js guide shows how
Any other frameworkLet Bolt tell you which file renders the HTML head, then edit it

In a Vite project, paste the tag before the closing </head> tag of index.html:

<head>
  <meta charset="UTF-8" />
  <title>My app</title>
  <script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
</head>

Click Save or press Ctrl+S when the tag is in place.

How do you publish the change?

Open the Publish menu. Click Publish for a first release, or Update when the site is already live. Bolt does not apply edits to the live site until you do.

Loogika tracks route changes inside the app as pageviews automatically. SPA Navigation in Site Settings controls that, and it is on for a new site.

How do you check that Loogika is installed?

Open the published app in another tab and visit a few pages. The pageviews show up in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and look for script.js?siteId=, then see the script troubleshooting page.

What if Bolt removes the Loogika tag later?

A later prompt can make Bolt generate index.html or the layout file again, and the tag can disappear with the old file. You have two ways to prevent that.

  • In the Files list, right-click the file and pick Lock file. Bolt then leaves the file alone.
  • Add a line to the Knowledge of the project that tells Bolt to keep the Loogika script tag.

Does the tag work in an Expo project?

Only in the web build. A script tag does not run inside the native mobile app. A native app can send events to Loogika over HTTP instead, as described on the page about sending events through the API.

Why do the numbers differ from Bolt's Analytics?

Crawlers and bots are part of the built-in counts that Bolt shows. Loogika removes known bots from its reports while Site Settings has Block Bot Traffic switched on, which it is for a new site.