Installation guides
Bolt
Add ProductLense to an app built with Bolt by pasting one prompt, then check that the tags in index.html or the root layout are unchanged.
Bolt writes the code for you, so the install is a prompt. Most Bolt projects are Vite apps with an index.html; some are Next.js or Astro projects. The prompt below covers each, and asks for the exact tags, because an AI that "improves" the tag can break it.
Replace SITE_ID in the prompt with the id from Settings → Sites in the ProductLense dashboard before you send it.
The prompt
Add ProductLense analytics. Use plain script tags, exactly as written below, and do not install any package.
- If the project has an index.html (Vite), put both tags inside <head>, before any other script.
- If it is Next.js, add them to app/layout.tsx with next/script: the first as an inline Script with strategy="beforeInteractive", the second with strategy="afterInteractive".
- If it is Astro, put both tags in the <head> of the shared layout, with is:inline on each.
<script>window.productlense=window.productlense||function(){(window.productlense.q=window.productlense.q||[]).push(arguments)}</script>
<script defer data-site="SITE_ID" data-scroll="true" data-clicks="true" src="https://api.productlense.app/a.js"></script>
Do not convert them to a module, a component or an npm import, and do not change data-site or src. When a user signs in, call window.productlense?.('identify', user.id, { email: user.email, name: user.name }) once with the signed-in user's id. Then add window.productlense?.('event', name, props) at the actions that matter, 8 to 15 in total: signup_completed, each onboarding step, the first use of the main feature, checkout_started, upgrade and cancel clicks and similar. Names are lower-case words joined with underscores; props are a small flat object with no emails, names or tokens. If the project creates checkouts (Stripe, Lemon Squeezy, Polar, Dodo Payments, Paddle or Razorpay), read the visitor id with window.productlense('visitorId', callback) when the checkout starts and store it on the checkout as metadata pl_visitor_id. Finish with a list of the events you added and where each fires, and whether checkouts carry the visitor id.Check what the AI wrote
Open the file Bolt changed (index.html, app/layout.tsx or the Astro layout) and confirm:
data-siteholds your real site id, notSITE_ID.- The
srcis exactlyhttps://api.productlense.app/a.js. - The tag has no
type="module"and is not imported from a.tsor.tsxfile. The script reads its settings from its own tag, which only works for a classic script.
The hand-written versions are in the React (Vite), Next.js and Astro guides.
Bolt previews your app on its own domain. Add the domain you deploy to (Netlify, or your own) to the site's hostnames in the ProductLense dashboard; visits from the preview domain are rejected unless you add it too.
Verify your installation
- Deploy the app, then open the published URL in a normal browser window.
- Open the Live page in the ProductLense dashboard. Your visit appears within a few seconds.
- In the browser's developer tools, the Network tab shows a
POSTtohttps://api.productlense.app/api/ewith status204.
If the visit does not appear, follow Verify your installation.