Install on React, Vite, and single-page apps
Add Graytower to a React, Vue, Svelte, or other single-page app built with Vite or a similar tool.
Single-page apps load one HTML file and change pages in the browser. Graytower counts those page changes automatically.
Add the snippet
- Copy your snippet from Website → Settings → Tracking in Graytower.
- Open your app's
index.html(in Vite projects, it is in the project root). - Paste the snippet inside
<head>. - Build and deploy.
<!doctype html><html lang="en"> <head> <meta charset="UTF-8" /> <title>Northstar</title> <!-- Paste your Graytower snippet here --> </head> <body> <div id="root"></div> <script type="module" src="/src/main.tsx"></script> </body></html>Using Next.js? Follow the Next.js App Router instructions instead.
How page changes are counted
Graytower sends a pageview whenever the URL path changes, including through your router's links and the browser's back button. You do not need to call anything on each route.
Routes that only change the part after # (such as /#/pricing) are not counted as separate pages. Use path-based routing if you want each page reported.
Send custom events from your code
Call the tracker from your components after an action succeeds:
window.graytower?.("account_created", { plan: "pro" });If your app calls Graytower during startup, before the script has loaded, add the preload queue. For TypeScript, declare the global once:
declare global { interface Window { graytower?: (event: string, params?: Record<string, unknown>) => void; }}export {};Check it's working
Open your deployed app on your registered domain. Local development on localhost is not tracked. In Graytower, look for Receiving events under Website → Settings → Tracking.