Install Datasense on your website
Where the Datasense script goes on every platform: Next.js, React, Vue, Astro, WordPress, Shopify, Webflow, Framer, Squarespace, Wix and more.
The script is the same everywhere: load it once on every page, inside <head>. Don't bundle it or add it twice. Copy it from Settings → Installation, where your site ID is filled in.
<script
defer
data-website-id="YOUR_SITE_ID"
src="https://usedatasense.com/js/script.cookies.js"
></script>There are two builds. /js/script.cookies.js (the default for new sites) recognizes returning visitors with a first-party cookie. /js/script.js stores nothing on the device. See GDPR and cookieless tracking.
Guides
- Next.js
- React, Vite and React Router
- Vue.js
- Astro
- WordPress
- Shopify
- Webflow
- Framer
- Squarespace
- Wix
- Google Tag Manager
- Lovable, Bolt and v0
Single-page apps
Route changes made with the History API (React Router, TanStack Router, Vue Router, SvelteKit, Astro view transitions) count as pageviews on their own. No extra code is needed.
Install with an AI code editor
Paste this prompt into Cursor, Claude Code, Windsurf or Copilot. The setup page in the dashboard has it with your site ID filled in.
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.