Add Datasense to Lovable, Bolt and v0
How to add Datasense to an app built with Lovable, Bolt, v0 or another AI app builder.
AI app builders change the code for you, so ask them to. Paste this prompt into the chat. Lovable and Bolt build Vite apps, so the script goes in index.html; v0 builds Next.js apps, so it goes in app/layout.tsx.
prompt
Install the Datasense analytics script on my website (example.com).
Load this script on every page, inside <head>:
<script
defer
data-website-id="YOUR_SITE_ID"
src="https://usedatasense.com/js/script.cookies.js"
></script>
- Next.js: use next/script in the root layout with strategy="afterInteractive" and keep the data-website-id attribute.
- Plain HTML or a static site generator: add the tag to the shared layout or head template.
- Don't add it twice, and don't bundle it: it must load from the src URL above.
Optional goal tracking: call window.datasense?.("signup", { plan: "pro" }) after key actions, or add data-ds-goal="checkout" to a button.
This is the cookie script: it sets first-party datasense_vid and datasense_sid cookies so returning visitors are recognized. If the site has a cookie consent banner, list them there as analytics cookies.
Optional, only if I ask for it: for signed-in users, call window.datasense?.("identify", user.id, { name, email }) once they're signed in, and window.datasense?.("reset") on sign-out.Replace
YOUR_SITE_IDwith your site ID from the dashboard.
Verify installation
After you deploy:
- Visit your live website.
- Open the Realtime page of your Datasense dashboard. Your visit shows up within a second, and the setup page says "Receiving events".
Datasense ignores localhost so you don't count your own development traffic. Add
data-allow-localhost="true"to the tag to test locally. More options are in the script configuration reference.