Skip to main content
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.
Replace 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

Grain is cookieless by default. When you need explicit consent handling:
Consent modes:
  • auto (default) — Cookieless analytics, no consent required
  • opt-in — No tracking until the user grants consent
  • opt-out — Tracking by default, user can revoke
Next steps: See the Grain Tag (Script) guide for complete examples including forms, navigation tracking, and more.

npm Package

For React, Next.js, and other apps with a build step, install @grainql/tag:
The package includes:
  • Core analytics SDK
  • Automatic tracking (page views, heatmaps, scroll depth)
  • Privacy-first identity (cookieless by default)
  • Full TypeScript support

Import and Use

Next steps: Check out the React Quick Start or Next.js Quick Start for complete examples.

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:
Check your dashboard — the event should appear within seconds.

npm Package

Check your browser console to see batching and sending activity.
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