DataSag guides · Updated 27 October 2026

Verify DataSag analytics on Docusaurus

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 Docusaurus.

Start with the Docusaurus installation

Add an object to the existing Docusaurus scripts array with src, defer and data-datasag-key attributes. Preserve the rest of your configuration. Build and serve the generated production site, then test a documentation route directly and through client navigation. The config runs in Node.js, so browser event calls do not belong there.

Docusaurus accepts string script entries, but an object is needed here to preserve the public tracking-key attribute and explicit non-blocking loading. Do not also insert the tracker through a client module, swizzled theme component or individual MDX page.

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 Docusaurus

  1. Inspect the scripts array in the configuration used for the production build. Confirm the DataSag entry is an attribute object with the public key, rather than a string URL that cannot carry the required data attribute.
  2. Build and serve the generated documentation, then open a deep document directly. Inspect its script element and pageview payload. Include a versioned or localized route if your deployment publishes those variants under the same configuration.
  3. Follow a Docusaurus internal link to another pathname and use Back. The tracker should remain installed while navigation changes the page path. Check the request path rather than expecting the external script to download on every transition.

The generated site preserves the key attribute and tracks direct and client-side documentation navigation from one installation.

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 Docusaurus

The shared installation belongs in the scripts array in docusaurus.config.js or docusaurus.config.ts. Use this as the installation reference while checking the procedure above.

// Merge this entry into the existing scripts array.
export default {
  scripts: [{
    src: "https://www.datasag.com/tracker.js",
    defer: true,
    "data-datasag-key": "YOUR_PUBLIC_KEY"
  }]
};

Related Docusaurus guides

Full Docusaurus setup guide · Search and AI visibility

References

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