CMS & blogs · 3 min setup
How to add analytics to a Ghost site
Updated
Ghost sites are often a publication and a newsletter at once, so the question that matters is which sources bring members, not just readers. The steps below install the tag and add a few lines that record a signup event when a new member confirms their email.
Ghost at a glance
- Where the tag goes
- Settings → Code injection → Site header
- Plans
- Every Ghost(Pro) plan and self-hosted Ghost
- Per post
- Post settings → Code injection (optional)
- Member signups
- Footer script reading Ghost's confirmation URL
- Paid members
- Ghost's own Stripe checkout isn't attributed
How to install VisitTrack on Ghost
Step 1: Copy your site id
Add your Ghost domain as a site in VisitTrack and copy the snippet from the install step. Replace
SITE_IDbelow.Step 2: Open Settings → Code injection
In Ghost Admin, open Settings (the gear) and find Code injection under the advanced settings. You'll see Site header and Site footer.
Step 3: Paste the tag (with the queue stub) into Site header
The first line is VisitTrack's queue stub: it lets the signup snippet in the next step call the tracker before the deferred script has loaded.
Site header<script>window.visitrack=window.visitrack||function(){(window.visitrack.q=window.visitrack.q||[]).push(arguments)}</script> <script defer data-site="SITE_ID" src="https://visitrack.app/tracker.js"></script>Step 4: Count confirmed member signups (Site footer)
When a new member clicks the confirmation link in their email, Ghost brings them back with
actionandsuccessparameters in the URL. This snippet turns that into asignupevent. Check the address bar after a test signup to confirm the parameters on your Ghost version.Site footer<script> // Ghost adds ?action=signup&success=true when a new member confirms // (older versions used action=subscribe). (function () { var p = new URLSearchParams(location.search); var action = p.get("action"); if ((action === "signup" || action === "subscribe") && p.get("success") === "true") { window.visitrack("signup", { source: "ghost_portal" }); } })(); </script>Step 5: Save
Click Save. Code injection is live immediately — no theme upload or restart.
How to check VisitTrack is working on Ghost
- Open your site in a private window and read a post.
- VisitTrack's live view shows you within seconds; posts appear by slug in the Pages tab.
- Sign up with a test email, click the confirmation link, and check the Signups tab — the
signupevent appears with the source of that visit.
Does VisitTrack track Ghost page navigation?
Ghost themes render each post, page and archive as a full page load, so every page is a pageview. Paginated archives (/page/2/) have their own paths. The Portal popup (sign up, sign in, account) opens over the current page without changing the path, so it doesn't add pageviews.
How to track custom events and goals in Ghost
Ghost's Portal runs inside an iframe, and VisitTrack's script deliberately doesn't run in iframes — which is why the signup snippet above reads the URL of the page members return to instead.
To see which calls to action drive signups, add data-vt-goal to the Portal buttons in your theme (they carry data-portal="signup"), and data-vt-scroll to the end of your post template to measure read-through. These are theme edits; upload the theme zip again afterwards.
<a href="#/portal/signup" data-portal="signup" data-vt-goal="subscribe_click">Subscribe</a>
<!-- at the end of post.hbs -->
<div data-vt-scroll="post_read_to_end"></div>Make signup a goal in Settings → Goals, and build a funnel post page → subscribe_click → signup to see where readers drop off.
Revenue attribution on Ghost
Paid memberships go through Ghost's own Stripe checkout, which doesn't pass a VisitTrack visitor id, so those payments can't be attributed — connecting the same Stripe account would bring in payments VisitTrack can't match to a visitor. Member signups by source (above) are the reliable growth metric for a Ghost publication.
Script options you might need on Ghost
All optional — add them to the same tag. Full reference: script configuration.
| Attribute | What it does |
|---|---|
data-cookieless | Store nothing in the browser; the server derives a daily-rotating id. See cookieless mode. |
data-exclude="/app/*" | Never track these paths (comma-separated, * wildcard). Checked on every navigation. |
data-allow-local | Track on localhost and *.local — for testing an install only. |
data-debug | Log every event the script sends, and why it skipped one, to the console. |
data-auto="false" | Turn off automatic events (downloads, contact clicks, form submits, rage clicks, JS errors, 404s). |
Ghost troubleshooting
The signup event never fires
Check the URL after confirming a test signup. If Ghost uses different parameters on your version, adjust the condition. The queue stub must be in Site header above the tracker, or window.visitrack won't exist yet.
Signups are counted twice
Refreshing the confirmation URL runs the snippet again. Ghost normally clears the parameters; if yours doesn't, ignore occasional repeats or dedupe in a funnel by visitor.
Your own visits show up
Open the site once with ?vt_ignore=1 in the URL in each browser you write from.
Theme attributes don't work
Theme edits only apply after you upload the updated theme zip in Ghost Admin's theme settings (Design → Change theme → Upload theme).
Ghost analytics FAQ
How do I add a tracking script to Ghost?
Settings → Code injection → Site header, paste the tag and save. It's available on every Ghost(Pro) plan and on self-hosted Ghost, and it applies to every page of the site.
Can VisitTrack track Ghost newsletter signups?
Yes. The Site footer snippet above records a signup event when a new member confirms their email, attributed to the visit's source. Turn it into a goal to see signups per referrer or campaign.
Why can't VisitTrack see inside Ghost Portal?
Portal runs in an iframe, and the VisitTrack script intentionally doesn't run inside iframes. Tracking the confirmation return and the buttons that open Portal covers what matters.
Does VisitTrack replace Ghost's built-in analytics?
It complements it. Ghost's analytics focuses on members and email; VisitTrack adds UTM/channel breakdowns, journeys, live visitors, AI-crawler tracking and an API.
Do I need a cookie banner on Ghost with VisitTrack?
Not in cookieless mode, which stores nothing in the reader's browser. Ghost's own member login uses cookies, which is separate. General information, not legal advice.
Keep going
- WordPress analyticsAdd VisitTrack to WordPress with a header-code plugin or a wp_head hook — works with block themes, caching plugins and WooCommerce.
- Squarespace analyticsAdd VisitTrack to Squarespace 7.1 in Pages → Website Tools → Code Injection → Header, on Core, Plus or Advanced plans.
- Jekyll analyticsAdd VisitTrack to Jekyll (and GitHub Pages) through _includes/head.html or Minima's custom-head.html, production-only via jekyll.environment.
- Hugo analyticsAdd VisitTrack to a Hugo site through your theme's head partial, loaded only in production with hugo.IsProduction, plus a shortcode for goals.
- Install the tracking scriptThe reference tag, CSP notes and how to check it's working.
- Custom events and signupsvisitrack(), data-vt-goal, scroll events and server-side signups.
- Use casesHow SaaS teams, indie hackers, stores and agencies use VisitTrack.
- VisitTrack vs Google AnalyticsCookie-free analytics with revenue attribution, compared honestly.
Add VisitTrack to your Ghost site
Cookie-free analytics with revenue attribution, live visitors, funnels and session replays. One script tag, every feature on every plan. 14 days free, no card required.
Not on Ghost? See all 29 integration guides.