DataSag guides · Updated 27 October 2026

Fix duplicate analytics pageviews on Shopify storefront themes

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 Shopify storefront themes.

Start with the Shopify storefront themes installation

Back up or duplicate the theme first. Add the tracker to layout/theme.liquid before </head>, using the public key for the storefront project. Save the theme and test the published storefront. This is a theme integration, not a Shopify app installation.

The theme does not control every checkout or customer account document. A storefront pageview does not prove a completed order. Do not claim this snippet measures checkout pages or purchase revenue without a separate supported integration.

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 Shopify storefront themes

  1. Search the live theme layout and rendered snippets for DataSag. Check whether a previous manual install remains alongside an app or global injection mechanism. Keep a backup before removing a theme entry.
  2. Remove only the redundant owner in the intended theme, then publish that theme. A successful preview of the corrected duplicate does not change the currently live storefront.
  3. Test product and collection pages on the public store. Inspect null-name pageview payloads and keep cart clicks, heatmap events, and other named actions separate. Do not use an order count as the expected storefront pageview count.

The published storefront emits pageviews from one installation without confusing product interactions with duplicate loads.

Complete the collection checks

  1. 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.
  2. 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.
  3. Remove redundant script insertion mechanisms, keeping the site-wide installation. Two copies execute independently even when their browser download is cached.
  4. 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.
  5. 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 Shopify storefront themes

The shared installation belongs in layout/theme.liquid before the closing head tag. 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 Shopify storefront themes guides

Full Shopify storefront themes setup guide · Search and AI visibility

References

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