npm package
Install the browser tracker from npm.
Last updated June 3, 2026
Install the browser tracker from npm when your app needs explicit pageview, custom event, or revenue calls.
Prerequisites
- A Grometrics site ID from Settings > Tracking
- Access to the site, theme, or app code
- A way to publish the change
Steps
Install the package
Add the tracker dependency.
terminal
1npm install @grometrics/webInitialize
Start the tracker once when the app boots.
Replace YOUR_SITE_ID with your site ID from Settings > Tracking.
analytics.ts
1import { initGrometrics } from '@grometrics/web'23export const analytics = initGrometrics({ siteId: 'YOUR_SITE_ID' })
Send events
Use the returned analytics object for route changes, custom events, and revenue.
Options / Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| siteId | string | ✓ | Your Grometrics site ID |
| debug | boolean | no | Logs verification details during setup |
npm
1npm install @grometrics/webWhat happens next
Trigger a pageview or custom event, then confirm it in Realtime.
Verify your setup
Verify your setup
Troubleshooting
No event appears
Confirm the site ID matches Settings > Tracking and that the latest published code is running.
Was this page helpful?