BeaconMetric is a lightweight web analytics tool that tracks page views, Core Web Vitals, and custom events without cookies or personal data collection. This guide will have you collecting data in under two minutes.
Add the following script tag to your site's <head> or before the closing </body> tag. Replace the site ID with your own (found in your dashboard under Settings).
<script src="https://beaconmetric.com/s/YOUR_SITE_ID/beacon.js" defer></script>
The script is less than 1KB gzipped and loads asynchronously, so it won't affect your page load performance.
If you prefer a package manager, install the official SDK:
npm install @beaconmetric/browser
Then initialize it in your application entry point:
import { init } from '@beaconmetric/browser';
init({ siteId: 'YOUR_SITE_ID' });
BeaconMetric works out of the box with zero configuration. Core Web Vitals (LCP, CLS, INP, TTFB, FCP) and page views are tracked automatically. To customize behavior, pass an options object:
init({
siteId: 'YOUR_SITE_ID',
trackVitals: true, // default: true
trackPageviews: true, // default: true
respectDNT: true, // default: true
apiEndpoint: 'https://beaconmetric.com'
});
Track any user interaction with a single function call:
import { track } from '@beaconmetric/browser';
track('signup', { plan: 'pro', source: 'landing' });
Event names are case-insensitive and can include up to 10 custom properties.