# Ghost analytics with CrispStats

Updated 2026-11-23

To add CrispStats to a Ghost publication, paste the script tag into the Site header box under Settings, Advanced, Code injection in Ghost Admin, and save. Ghost outputs that code inside the head of every page, so you do not edit your theme, and a theme change does not remove it.

## Steps

### 1. Copy the tag with your key

In the CrispStats dashboard, open your site's **Settings**, select **Tracking code** and copy the tag from the **HTML** tab. Replace `example.com` with your publication's domain if it is not filled in. The public key starts with `cs_pk_` and is safe to publish.

```html
<script
  defer
  data-site="cs_pk_your_site_key"
  data-domains="example.com"
  src="https://in.crispstats.com/d.js"
></script>
```

### 2. Open Code injection in Ghost Admin

Ghost's [help page on code injection](https://ghost.org/help/code-injection-styles/) puts it under **Settings**, **Advanced**, **Code injection**. Code in **Site header** is output inside `<head>`; code in **Site footer** goes before `</body>`.

### 3. Paste it into Site header and save

Paste the tag into **Site header** and save. Use the site-wide box, not the code injection of a single post, so every post, tag page and author page is covered.

### 4. Open your publication signed out

Open your site in a private window, signed out of Ghost Admin, and read a post or two.

### 5. Turn on extra events (optional)

Add attributes to the tag in **Site header**. `data-outbound` counts clicks on links to other sites, so you see which links in your posts get used. `data-404` sends a `404` event on not-found pages that carry the marker; see [404 pages](/docs/track/404-pages).

```html
<script
  defer
  data-site="cs_pk_your_site_key"
  data-domains="example.com"
  data-outbound
  data-404
  src="https://in.crispstats.com/d.js"
></script>
```

### 6. Count a click inside a post (optional)

In an HTML card, give a link or button a `data-cs-event` attribute, with properties from `data-cs-prop-` attributes. No JavaScript is needed.

```html
<a href="https://example.com/course" data-cs-event="course click" data-cs-prop-post="launch-notes">See the course</a>
```

## Check that it works

Open a post with the developer tools on the **Network** tab. You should see `d.js` load from `in.crispstats.com` and a `POST` to `/e` that gets `202`, and the visit appears on the **Realtime** screen within seconds. If the tag is missing from the page source, your theme may not output Ghost's head code: themes must include `{{ghost_head}}` in their default layout.

## What you get

- Pageviews, unique visitors and sessions for every post, page, tag archive and author page.
- Where readers come from: search, social, newsletters whose links carry [UTM parameters](/glossary/utm-parameters), and AI assistants such as ChatGPT and Perplexity, as their own channel.
- [Entry pages](/glossary/entry-page), so you see which posts bring new readers in, with countries, devices and browsers.
- Clicks on outbound links in your posts, and member sign-ups as [goals](/glossary/goal) when the sign-up flow ends on a page you can name.
- A [public dashboard](/features/public-dashboards) to share readership numbers with sponsors through a read-only link, off by default.

## Notes for Ghost

- CrispStats does not report on newsletter subscribers, email opens or clicks inside emails. Ghost stays the place for those; links from your newsletter show as a source once they carry UTM parameters.
- Members and anonymous readers are counted the same way, with an anonymous visitor id that rotates daily. It does not know who is a member unless you call `crispstats.identify()` yourself.
- Ghost's code injection help page does not state a plan requirement, and the Ghost(Pro) pricing page read on 2026-11-23 does not list code injection by plan. If you do not see it, check with Ghost what your plan includes.
- Each Ghost page is a full page load, so one pageview per post. A pop-up that only changes the part of the URL after `#` is not a new page.
- On a self-hosted Ghost behind nginx, you can serve the script from your own domain with one forwarding rule: see [the proxy guide](/docs/tracking/proxy).

Full reference: [Ghost in the docs](https://docs.crispstats.com/install/ghost)

## Frequently asked questions

### Do I need to edit my Ghost theme?

No. Code injection is a site setting, separate from your theme, so the tag stays when you switch or update themes. The theme only needs to output Ghost's head code, which standard themes do.

### Does it replace Ghost's own analytics?

It answers different questions. Ghost covers members, newsletters and email opens, which CrispStats does not. CrispStats adds sources, AI assistant referrals, entry pages, outbound clicks and web vitals without cookies.

### Does it count members and anonymous readers separately?

No. Every visit is counted the same way with an anonymous daily visitor id. To tie visits to a member, call identify from your own code after sign-in.

### Do I need a cookie banner for analytics on Ghost?

CrispStats sets no cookies and stores nothing on the reader's device by default. Ghost's member sign-in and other scripts may, so check the whole site. This is not legal advice.

### What does it cost for a Ghost blog?

Each post view is one event. Every account starts with a 14-day free trial with every feature, public dashboards for sponsors included, and no card; then Starter is $5 a month for 250,000 events.

## Related

- [Privacy-friendly analytics for bloggers](/for/bloggers)
- [Track visitors from ChatGPT and Perplexity](/blog/track-ai-traffic-chatgpt-perplexity)
- [UTM parameters: a practical guide](/blog/utm-parameters-guide)
- [Public dashboards](/features/public-dashboards)
- [WordPress analytics](/integrations/wordpress)
- [Jekyll analytics](/integrations/jekyll)
