Skip to content

PureMetrix npm package

Install PureMetrix from npm for single-page apps and component-based projects—pageviews, custom events, and typed helpers without pasting script tags everywhere.

When to use the package

  • React / Vue / Svelte apps with client-side routing
  • Design systems that want a single analytics module
  • Teams that already manage third-party code via package.json

When a script tag is enough

Marketing sites and WordPress sites can use the tracking script or the WordPress plugin. The npm package is the better fit when you need route hooks and custom events inside your application code.

Example

import { init, track } from '@puremetrix/tracker';

init({
  domain: 'example.com',
  key: 'YOUR_PUBLIC_KEY',
  api: 'https://collect.puremetrix.org/api/event',
  scriptSrc: 'https://collect.puremetrix.org/js/script.js',
});
track('SignupClick', { props: { plan: 'growth' } });

By default, the package expects a same-origin proxy (/px/event, /px/js). For PureMetrix Cloud, set api and scriptSrc as above. For Next.js (provider + App Router pageviews): Next.js integration docs. Package name: @puremetrix/tracker (also @puremetrix/tracker/react).

Related

Next.js docs

Last updated: September 2026