Get started
Install & verify
One script tag records traffic on every page that loads it.
Paste the script before </head>
Replace
YOUR_SITE_IDwith the public site ID from your site's Settings → Install card. The site ID is public and safe in browser code; never put your secret key in a page.Your website's shared layout<script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID" ></script>Framework apps should put it in their shared layout so every route loads it. See the installation guides for platform-specific steps.
Deploy and open your website
Publish the change, then open the live site in your browser.
Check the Network panel
Find
script.js, then a request to/api/v1/collect. A successful collection response containsok: true.Refresh Traffic
Open Traffic and choose Refresh. The reporting window must include your visit.
Verify it works
Open your live website in a normal browser window (not an automated or embedded one). In the browser's Network panel, look for script.js and then a request to /api/v1/collect whose response contains ok: true. Open your site's Traffic tab and choose Refresh; the selected dates must include your visit.
Nothing showing? See Troubleshooting.
What the script records
Pageviews, single-page-app navigation, time on page, sources and campaign tags, devices, available location data and outbound clicks.
Not tracked by default:
- Automated browsers (for example headless or test automation).
- Pages loaded inside an iframe.
localhostand other local development hostnames, unless you adddata-allow-localhost.- Browsers you excluded (see Exclude your visits).
A visit can also be excluded by your site settings or blocked by a browser extension.
Optional attributes
Add these to the same script tag. Don't install a second tracker.
| Attribute | Effect |
|---|---|
| data-domain="example.com" | Share a persistent visitor cookie across this domain and its subdomains after storage consent. |
| data-api="/a/event" | Send events through your own server. See Use your own domain. |
| data-auto-pageviews="false" | Disable automatic pageviews and call analytics.pageview(path) yourself. Other event tracking stays on. See SPA & virtual pages. |
| data-track-hash="true" | Opt in to #/... and #!/... router paths. Hash query parameters and ordinary anchors or OAuth fragments are omitted. |
| data-strip-query="true" | Omit URL query strings from transport. Recognized hash routes still work when enabled; UTM and referral fields remain separate. |
| data-allow-localhost | Opt in to tracking local development. Add the local hostname to this site's allowed domains too. |
Details
- The script reads its settings from its own
<script>element. Tools that bundle, combine or rewrite scripts can drop thedata-*attributes; exclude the MetricRaven script from them if collection requests never appear. - If tracking is skipped (automation, iframe, localhost or an excluded browser),
window.analyticsstays callable so your page doesn't break, but nothing is sent.