Server-side tracking uses
@grainql/analytics-web, a separate package from @grainql/tag. Grain Tag is for browser-side analytics. For browser tracking, see Installation.Install the Package
npm
yarn
pnpm
Initialize the SDK
Track Server-Side Events
Serverless environments: Use
{ flush: true } to send events immediately before the function terminates. Otherwise, events might not get sent.Track Background Jobs
Use Remote Configuration
Control server-side behavior without redeploying:Express.js Middleware
Track all requests automatically:Fastify Plugin
AWS Lambda Example
Vercel Serverless Functions
Track User Events Server-Side
Associate events with specific users:Error Tracking
Track backend errors to understand failure patterns:Testing Your Integration
What’s Next?
Core API Reference
See all available methods and options
Authentication
Learn about server-side authentication
Query API
Query your analytics data programmatically
Configuration Guide
Advanced configuration options