DataSag guides · Updated 27 October 2026
Fix duplicate analytics pageviews on Jekyll
Multiple tracking requests do not necessarily mean duplicate pageviews. DataSag sends pageviews, scroll milestones, engagement updates and custom events. Inspect eventName before removing code. This guide applies to Jekyll.
Start with the Jekyll installation
Find the layout chain used by your Jekyll pages and posts. Add the deferred script once to the shared head template or its include. Keep the existing Liquid content and include structure, build the site and deploy the generated output. A theme-provided layout can require a local override rather than editing a gem.
Front matter selects layouts, and a page can bypass the shared default layout. Check standalone pages, posts and archive templates. Updating a source layout does not update a hosted site until the build and publication step completes.
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 duplicate analytics pageviews in Jekyll
- Search the base layout, head includes, post layouts and content for tracker.js. An inherited default layout plus a second script in the post layout or a Markdown HTML block can produce multiple installations in one output file.
- Inspect theme configuration or plugins that may add analytics separately. Choose one installation owner and preserve other theme includes; deleting an entire head include can remove metadata and unrelated resources along with a duplicate tracker.
- Rebuild and inspect the final generated document before opening it publicly. Then reload one post and review eventName in the request payloads. Scroll milestones and engagement updates are legitimate event categories rather than extra document pageviews.
The rendered layout chain contains one tracker, and unrelated head content survives the duplicate cleanup.
Complete the collection checks
- Open Network and filter /api/track. Reload once without clicking or scrolling. Inspect eventName in each payload: null identifies a pageview; scroll, click_heatmap and __datasag_engagement are other records.
- Count rendered script elements with data-datasag-key. There should be one intended installation for this project. Search your code, site header settings, embeds and tag manager for additional copies.
- Remove redundant script insertion mechanisms, keeping the site-wide installation. Two copies execute independently even when their browser download is cached.
- Check for custom router listeners that manually send pageviews. The current tracker handles pushState, replaceState and popstate and ignores a repeated pathname. Do not add a second pageview implementation without a demonstrated gap.
- Repeat a direct load, a second route and browser Back. Correlate pageview records with actual path changes. A query-only change on the same pathname is not a new pageview in the current tracker.
[...document.querySelectorAll('script[data-datasag-key]')]
.map(script => ({
src: script.src,
key: script.getAttribute('data-datasag-key')
}));What a successful check looks like
A single installation and one pageview dispatch for each actual pathname change in the tested sequence. Additional engagement records remain available.
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
Comparing the total number of events with the number of pageviews produces a false duplicate diagnosis. Keep the event categories separate throughout the check.
Installation snippet for Jekyll
The shared installation belongs in the head of the shared _layouts/default.html or its head include. 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 Jekyll guides
References
Official Jekyll documentation covers the integration point. For DataSag data handling, read the privacy policy. Use support if a request fails after these checks.