Installation guides
Install on Ghost
Ghost's site-wide Code injection adds the tag to the head of every page and post.
Open Settings → Advanced → Code injection
In Ghost Admin, choose the gear icon, then find Code injection under Advanced.
Paste the snippet into Site header
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.Site header<script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID" ></script>Use Site header, not Site footer or the code injection on a single post.
Save and open your site
Open a page on your public domain in a private window.
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.
Alternative: add it to your theme
On a self-hosted Ghost, or a plan that allows custom themes, you can put the tag in your theme's default.hbs instead, before {{ghost_head}}. Re-add it when you switch or update the theme.
{{!-- default.hbs in your theme --}}
<head>
...
<script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID"></script>
{{ghost_head}}
</head>Notes
- Only hostnames listed in your site's Settings → General → Site domains (and their subdomains) are accepted. To also count visits on a platform address such as
your-site.ghost.io, add it there; otherwise those requests are refused withdomain_not_allowed. - Your own visits to the public site count like anyone else's. To leave them out, see Exclude your visits.
- Pair it with
data-goalattributes on your signup buttons to count member signups as goals. - If you use a cookie banner, connect it with Consent & visitor IDs.
Attribute sales
To credit Ghost sales to the visits that brought the buyer, connect Stripe and follow Attribute revenue with Ghost.
Optional script attributes are listed in Install & verify. To exclude your own visits, see Exclude your visits.