# Ghost

Add ProductLense to a Ghost publication through Code injection in the site header, with no theme edits.

Ghost has a site-wide code injection box that prints into the `<head>` of every page, including posts, tags and member pages. Paste the ProductLense script there and you do not need to touch the theme.

## Add the script

1. In Ghost Admin, open Settings → Code injection.
2. Paste the two tags into Site header. Replace `SITE_ID` with the id from Settings → Sites in the ProductLense dashboard.
3. Save.

```html title="Site header" {1-2}
<script>window.productlense=window.productlense||function(){(window.productlense.q=window.productlense.q||[]).push(arguments)}</script>
<script defer data-site="SITE_ID" src="https://api.productlense.app/a.js"></script>
```

## Identify members

Ghost themes can read the signed-in member with the `@member` helper. To link paying members to their first visit, add this to your theme's `default.hbs`, after `{{ghost_head}}`:

```handlebars title="default.hbs" {3}
{{#if @member}}
  <script>
    window.productlense('identify', '{{@member.uuid}}', { email: '{{@member.email}}' });
  </script>
{{/if}}
```

Sending the `email` trait lets ProductLense match Stripe payments for Ghost memberships by email. See [how payments are attributed](/docs/revenue/attribution) and [Stripe](/docs/revenue/stripe).

## Verify your installation

1. Open your publication in a normal browser window, signed out of Ghost Admin.
2. Open the Live page in the ProductLense dashboard. Your visit appears within a few seconds.
3. In the browser's developer tools, the Network tab shows a `POST` to `https://api.productlense.app/api/e` with status `204`.

A local Ghost install runs on `localhost`, where nothing is sent unless you add `data-dev="true"` to the tag. Ad blockers in your own browser may block the request. If the visit does not appear, follow [Verify your installation](/docs/install/verify).
