Install on Ghost
One snippet in Settings, Code Injection, Site Header counts every page, with no plan requirement for the basic install. Ghost Portal renders its sign-in and sign-up forms itself, and Code Injection cannot give them an id or a class, so a click-level goal on a Portal button needs a custom theme, which is Ghost’s Creator plan or higher. Pageviews are unaffected either way.
Before you paste anything
Every snippet below shows YOUR-SITE-ID
. Replace it with your own site id, which is on the Tracking Code page of the site in your account.
If you do not have an account yet, creating one and adding your domain takes about a minute.
Add the snippet to Code Injection
- In your Ghost admin, go to Settings, then Code Injection.
- Paste the snippet into the Site Header box.
- Click Save, then open your live site in a new tab.
<script>
(function () {
// Ensure this only runs in a browser environment.
if (typeof window === 'undefined' || typeof document === 'undefined') {
return;
}
var siteId = 'YOUR-SITE-ID';
var trackingDomain = 'www.veritametrics.com'; // 1. Initialize the Async Command Queue
// This ensures window.verita() is available immediately.
window.verita =
window.verita ||
function () {
(window.verita.q = window.verita.q || []).push(arguments);
};
window.verita.l = new Date().getTime(); // 2. Load the enhanced tracker script asynchronously.
// It will process the command queue once loaded.
var script = document.createElement('script');
script.src = 'https://' + trackingDomain + '/api/tracker.js?siteId=' + siteId;
script.async = true;
script.defer = true;
script.dataset.siteId = siteId;
script.dataset.trackingDomain = trackingDomain;
document.head.appendChild(script); // 3. Send the initial pageview using the *queue*
window.verita('trackPageView');
})();
</script>
<noscript>
<img
src="https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID"
referrerpolicy="unsafe-url"
alt=""
width="1"
height="1"
style="display: none"
aria-hidden="true"
/>
</noscript> Check that the data is arriving
- Open your site in a browser and load any page.
- In VeritaMetrics, open the site and click Tracking Code in the sidebar. The status turns active and your visit appears in the recent-pageviews list within a few seconds.
If nothing arrives, open your browser devtools on the Network tab and reload. You should see a request to /api/tracker.js that returns 200, then a request to /api/v1/c when you move or scroll.
A Portal sign-up click will not fire a custom event
Portal is Ghost’s own sign-in and sign-up flow, and Code Injection has no way to mark its buttons with an id or a class, so a click-based goal aimed at one never fires. Pageviews still count normally: track the page a new member lands on after signing up instead of the click itself, or move to a custom theme on the Creator plan or higher if you need the click.
Guides for other platforms
The same install, on a different stack.
Explore the documentation
Jump to another guide.