Looking for a quick start guide? Check out our platform-specific integrations for step-by-step setup instructions.
Choose Your Installation Method
Pick the method that fits your setup:Grain Tag (Script)
The primary way to install Grain — works everywhere
npm / yarn / pnpm
For React, Next.js, and apps with a build step
Grain Tag (Script)
The fastest way to add Grain to any site. Drop a single script tag in your HTML and you’re live.your-tenant-id with your tenant identifier (not UUID) from your dashboard.
The Grain Tag handles everything automatically: page views, click tracking, scroll depth, heatmaps, rage clicks, dead clicks, session management, and DOM snapshots.
Track Custom Events
Identify Users
Consent Management
Grain is cookieless by default. When you need explicit consent handling:auto(default) — Cookieless analytics, no consent requiredopt-in— No tracking until the user grants consentopt-out— Tracking by default, user can revoke
npm Package
For React, Next.js, and other apps with a build step, install@grainql/tag:
- Core analytics SDK
- Automatic tracking (page views, heatmaps, scroll depth)
- Privacy-first identity (cookieless by default)
- Full TypeScript support
Import and Use
Platform Support
Grain works across multiple environments:Browser
- Chrome, Firefox, Safari, Edge
- Modern ES6+ and legacy ES5
- Module bundlers (Vite, Webpack, esbuild)
Frameworks
- React
- Next.js (App Router & Pages Router)
- Vue, Svelte, Angular
- Vanilla JavaScript
Server
- Node.js 14+
- Serverless (AWS Lambda, Vercel, Netlify)
Verify Installation
Grain Tag (Script)
Open your browser console after adding the script tag. You should see Grain initialization logs. Then run:npm Package
Privacy & Consent
Grain is cookieless by default — no consent banner needed for basic analytics. Daily rotating IDs ensure user privacy without sacrificing analytics quality. When you need explicit consent management:GDPR Compliance: In the default
auto mode, Grain uses only ephemeral daily rotating IDs — no cookies or persistent tracking. Calling consent.grant() upgrades to persistent IDs stored in localStorage (not cookies). See Privacy & Compliance for full details.What’s Next?
Grain Tag (Script)
Complete guide with examples for script-based installation
React Quick Start
Hooks-based integration for React apps
Authentication
Set up Auth0 or custom JWT authentication
Tracking & Events
Learn about event tracking and best practices