DataSag guides · Updated 27 October 2026

Fix DataSag analytics not working on Grav 1.7 Twig themes

Find the first missing step in the delivery chain: published HTML, executing tracker, tracking request, successful response and project report. Changing several settings at once makes the failure harder to identify. This guide applies to Grav 1.7 Twig themes.

Start with the Grav 1.7 Twig themes installation

These instructions target Grav's documented 1.7 Twig theme structure. Find the active theme's templates/partials/base.html.twig and add the deferred tracker inside head. Preserve existing blocks, asset output and page content. Maintain the change in a custom or inherited theme rather than an unmanaged installed-theme edit, then clear relevant caches and inspect public output.

Grav page templates commonly extend the shared base, but modular pages and custom templates can use another structure. Check the active theme and inheritance before assuming the base file covers every route. Do not treat a browser tracker as a Grav backend plugin.

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.

Fix DataSag analytics not working in Grav 1.7 Twig themes

  1. Check the active theme configuration and the affected page's selected template. Editing a base file in another installed theme cannot alter the public page, and a custom template may bypass the shared partial entirely.
  2. Inspect the final public head after clearing the relevant cache. Confirm the script was not placed in a Twig block that another template fully replaces. Preserve asset output and other parent content when correcting inheritance.
  3. If only a form event is missing, inspect the browser success behavior of the installed form solution. A Twig conditional rendered on the initial request cannot observe a later asynchronous submission. Verify the tracker request separately from form delivery.

The investigation separates active-theme selection, cached Twig output and the actual browser boundary for form success.

Complete the collection checks

  1. Confirm the change reached the public domain. Inspect the live HTML and clear only caches that serve the old document. A saved editor change may still need publishing.
  2. Check that tracker.js exists in the Network panel and that the script contains the public key from the same DataSag project you are viewing.
  3. Check whether your test browser is excluded with datasag_ignore. Restore inclusion with ?datasag_ignore=false only if this browser should count. Respect any consent controls configured on your site.
  4. Inspect the browser Console for Content Security Policy or script errors. Check /api/track request responses: 400 indicates invalid input, 404 can indicate an unknown project key, and a server failure needs investigation rather than repeated snippet changes.
  5. Try a controlled browser profile to identify an extension block. Do not bypass a visitor's privacy preferences. Then check the project's selected date range, path and domain.
  6. Collect the affected public URL, approximate time, request status and installation location for support. Omit account credentials and visitor data from screenshots.
typeof window.datasag?.track
// If undefined, first investigate whether the script executed.

new URL(location.href).searchParams.get('datasag_ignore')
// Also check for a previously saved browser exclusion.

What a successful check looks like

The first failed boundary is identified and corrected, and a new controlled visit reaches the right project. The browser Console and Network panel provide the evidence.

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

Do not replace the public project key with a Supabase, Stripe or provider secret. The browser snippet uses only the project's public tracking key.

Installation snippet for Grav 1.7 Twig themes

The shared installation belongs in the head in the active theme templates/partials/base.html.twig. 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 Grav 1.7 Twig themes guides

Full Grav 1.7 Twig themes setup guide · Search and AI visibility

References

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