Installation guides
Install on WordPress
Add the script to your site's head on every page. Pick one of the two options below.
Option A: a header-code plugin
Copy your snippet
In MetricRaven, open your site's Settings → Install card and copy the script tag. It already contains your site ID.
Paste it into the plugin's header section
Use any plugin that inserts code into
<head>on all pages. Paste the snippet into its header field and save. ReplaceYOUR_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.Header code<script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID" ></script>
Option B: the wp_head hook
Add this to your child theme
Editing a child theme (or a small site-specific plugin) keeps the code when the parent theme updates.
functions.php<?php // In your child theme's functions.php (or a site-specific plugin). add_action('wp_head', function () { ?> <script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID" ></script> <?php });
Clear caches and check
If you use a page-cache plugin or host-level cache, purge it so visitors get the updated HTML.
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.
Notes
- Script optimizers that combine, inline or delay JavaScript can strip the script's
data-*attributes. If no collection request appears, excludemetricraven.com/js/script.jsfrom them. - Your own visits while logged in count like any other browser. Exclude them with the browser flag or an exclusion rule.
- If you use a cookie banner, connect it with Consent & visitor IDs.
Optional script attributes are listed in Install & verify. To exclude your own visits, see Exclude your visits.