- Grain Tag (
@grainql/tag) — The primary SDK for browser-side analytics. Cookieless by default, auto-tracks page views, clicks, scroll, sessions, and more. - Analytics Web (
@grainql/analytics-web) — For remote configuration, React hooks, template events, and server-side tracking.
Grain Tag
The default SDK for browser analytics. Lightweight, privacy-first, and SSR safe.Import Paths
Lifecycle
init(config?)— Creates the singleton instance and starts auto-trackingtrack(name, props?)/identify(userId)— Send events (works before init via pre-init queue)flush()— Force-send all pending eventsdestroy()— Tear down the SDK and clear the singleton
Quick Reference
Instance Methods
Analytics Web
For remote configuration, React hooks, template events, and server-side tracking.Import Paths
Quick Reference
Remote Configuration
Template Events
React Hooks
Return Values
- Synchronous methods: Direct values or
undefined - Async methods:
Promise<T>that resolves to the result - Hooks: Objects with data, loading states, and errors
Error Handling
Methods handle errors gracefully:- track(): Fire-and-forget, errors logged if debug enabled
- Config methods: Return cached/default on failure
- Async methods: Throw errors, catch with try/catch
- Hooks: Provide
errorproperty
Explore the API
Core Methods
Event tracking and user management
Config Methods
Remote configuration access
Template Methods
Pre-built event methods
React Hooks
React integration hooks
Types
TypeScript type definitions