DataSag guides · Updated 27 October 2026

Verify DataSag analytics on Ghost

A script tag alone does not confirm that analytics works. Verify the published document, the request to DataSag and the matching visit in the correct project. This guide applies to Ghost.

Start with the Ghost installation

Add the DataSag script to the site-wide Site Header area of Ghost Code Injection. Replace the example public key, save the change and open the public publication. Keep the active theme's ghost_head helper because that helper outputs header injection. This does not require a DataSag-specific Ghost integration.

Ghost also offers code injection for individual posts. A post-level snippet does not cover the publication, and a theme-level copy can duplicate a global injection. Test a published article and a standalone page outside Ghost Admin.

Use the public project key from the DataSag project you are inspecting. A test on a preview domain does not confirm that the production domain has the same code or settings.

Verify DataSag analytics in Ghost

  1. Inspect the publication-wide Site Header injection and compare it with the active theme. The theme must render ghost_head for this injection path to appear; preserve its other output when checking the tracking element.
  2. Open a published article as a signed-out visitor, then open a normal page and the publication homepage. Check the generated script element and /api/track request on each document rather than relying on an Admin preview.
  3. Inspect any article-specific injection for a second copy, then navigate through the public theme. Confirm requests name the article path and project key. A hosted membership screen outside the theme needs separate observation.

The public homepage, article and page share one intended injection, while theme coverage limits are recorded explicitly.

Complete the collection checks

  1. Open the published website in a normal browser window with the Network panel recording. Use a browser profile where you can control extensions and your consent choice.
  2. Filter network requests for tracker.js. Confirm it returns JavaScript successfully and that the rendered script has the project's data-datasag-key attribute. The example YOUR_PUBLIC_KEY must be replaced.
  3. Filter for /api/track and reload once. Inspect a request with eventName null or absent. Its projectKey and path should match the chosen project and the page you opened.
  4. Open that DataSag project, choose a date range containing today and inspect the matching path. Use the configured report timezone when checking dates.
  5. Navigate to a second path, then use Back. Compare pageview requests with the route changes rather than counting every request as a pageview.
document.querySelectorAll('script[data-datasag-key]').length
// Expected: 1

document.querySelector('script[data-datasag-key]')?.getAttribute('data-datasag-key')
// Expected: your project's public key

typeof window.datasag?.track
// Expected after the script runs: 'function'

What a successful check looks like

One rendered tracker installation, a successful request for the intended page and a corresponding entry in the intended project. Scroll and engagement requests are separate event types.

Record the public path you tested, the browser state, the approximate time and the observed request. Check one direct page load and one later navigation so the result covers more than the homepage.

Common mistake

A successful tracker.js download only proves that a file loaded. It does not validate the project key, consent state or tracking endpoint. Test a real published path before declaring setup complete.

Installation snippet for Ghost

The shared installation belongs in the site-wide Site Header code injection field. Use this as the installation reference while checking the procedure above.

<script defer src="https://www.datasag.com/tracker.js" data-datasag-key="YOUR_PUBLIC_KEY"></script>

Related Ghost guides

Full Ghost setup guide · Search and AI visibility

References

Official Ghost documentation covers the integration point. For DataSag data handling, read the privacy policy. Use support if a request fails after these checks.