Skip to content
Sign inStart free trial

Add the tracker

Add the following snippet to the <head> of every page you want to track:

<script
defer
data-domain="yourdomain.com"
src="https://app.metrixs.eu/tracker.js"
></script>

Replace yourdomain.com with your site’s domain (must match what you registered in MetriXs).

Attribute Description
data-domain Required. Your site domain
data-local-dev Set to track on localhost (disabled by default)

Beyond automatic pageviews, you can fire custom events for anything you want to measure — button clicks, video plays, form submissions, scroll milestones. Custom events appear in your dashboard and carry their own properties.

// Fire a custom event with properties
metrixs('Signup CTA Click', { props: { location: 'hero' } })
Option Type Default Description
name string The event name (e.g. 'Signup CTA Click'). Use 'pageview' for a manual pageview.
props object {} Custom properties to attach to the event.
url string location.href Override the page URL recorded for this event (useful for SPA route changes).
interactive boolean true Set to false for passive signals that should not count as a real interaction (so they don’t lower bounce rate). The built-in scroll-depth/engagement events use this.
callback function Called after the event is sent.
// Non-interactive signal — extends visit duration without affecting bounce rate
metrixs('scroll_to_bottom', { props: { article: 'gdpr' }, interactive: false })

Custom events that fire during a visit also extend its measured duration, because duration is calculated as the time between the first pageview and the last event. See Visit duration for why this matters.

The full tracker also captures three event types automatically — no setup required:

Event name When it fires Property
Outbound Link: Click A visitor clicks a link to an external domain url
File Download A visitor clicks a link to a file (pdf, zip, mp4, …) url
404 A 404 page — only if the page sets <meta name="metrixs:404" content="true"> path

These surface in their own Auto-tracked Events card on the dashboard. To capture 404s, add the meta tag to your 404 page template:

<meta name="metrixs:404" content="true" />

The lite tracker (tracker.lite.js) omits auto-tracking — pageviews only. Use the full tracker.js if you want outbound links, downloads, and 404s.

See Custom events for how to view and break them down in the dashboard.

To exclude your own visits, run this in your browser console:

localStorage.setItem('metrixs_ignore', 'true')

For minimal bundle size, use the lite tracker:

<script defer data-domain="yourdomain.com" src="https://app.metrixs.eu/tracker.lite.js"></script>