Skip to main content

Multiple analytics scripts are not redundantly loading the same data

ab-001717 · marketing-analytics.data-quality.no-redundant-scripts
Severity: infoactive

Why it matters

When the same tracking script loads twice — typically gtag.js direct plus GA4 nested inside a Google Tag Manager container — every pageview, every event, every conversion fires twice. Real conversion rates look 50% lower than they are, user counts double, session durations break because the same user is hitting consecutive pageviews in millisecond intervals, and automated bidding on ad platforms optimizes against phantom volume. The data contamination is permanent for the affected window.

Severity rationale

Info because redundant scripts corrupt data but the condition is rare and easy to remediate once spotted.

Remediation

Pick one loader for GA4 and remove the other. In app/layout.tsx, keep exactly one of these patterns:

// Option A: direct gtag
<Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} />
// Option B: GTM (which itself loads GA4)
<Script src={`https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`} />

If you ship Option B, remove every direct gtag.js tag. For Segment destinations, confirm no downstream destination has its own SDK initialized in the app.

Detection

  • ID: marketing-analytics.data-quality.no-redundant-scripts

  • Severity: info

  • What to look for: Multiple analytics tools can coexist intentionally (e.g., GA4 for marketing, PostHog for product, Vercel Analytics for infrastructure). However, some combinations are redundant and create data quality issues:

    • Both gtag.js loaded directly AND via Google Tag Manager (duplicate GA4 hits)
    • Both @vercel/analytics AND a full-featured alternative that already covers page views (some overlap, but generally acceptable)
    • The same Segment event piped to multiple destinations that also have their own SDK initialized (double-counting)
    • Multiple heatmap/session recording tools simultaneously (Hotjar + Clarity + PostHog recordings)
  • Pass criteria: Count every analytics script loaded in the application. Each analytics tool in use has a distinct, non-overlapping purpose, or only 1 analytics tool is used. 0 duplicate tracking scripts found.

  • Fail criteria: gtag.js is loaded both as a direct script AND via GTM with the same GA4 measurement ID, causing every event to be recorded twice. Any 2 or more scripts that track identical data to the same destination is a fail.

  • Skip (N/A) when: No analytics is present. Skip if only one analytics tool is used.

  • Detail on fail: "gtag.js script loaded directly in app/layout.tsx AND Google Tag Manager container script also found with GA4 configured inside GTM. This will double all GA4 hits."

  • Remediation: Choose one method for loading GA4: either load gtag.js directly in your app/layout.tsx, or load it via Google Tag Manager — not both. If you use GTM, remove the direct gtag.js script tag:

    // app/layout.tsx — pick ONE, not both:
    // Option A: Direct gtag.js
    <Script src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`} />
    // Option B: GTM (which loads GA4 internally)
    <Script src={`https://www.googletagmanager.com/gtm.js?id=${GTM_ID}`} />
    

Taxons

History