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

1

Install the package

Add the tracker dependency.

terminal

1npm install @grometrics/web
2

Initialize

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' })
3

Send events

Use the returned analytics object for route changes, custom events, and revenue.

Options / Configuration

OptionTypeRequiredDescription
siteIdstringYour Grometrics site ID
debugbooleannoLogs verification details during setup

npm

1npm install @grometrics/web

What 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?