gtag.js and GTM both running: how to spot double tags

Both hardcoded gtag.js and Google Tag Manager running on your site? How duplicate tags cause double pageviews, split sessions, and bad GA4 data.

When an established website undergoes a series of redesigns, agency handovers, or CMS theme updates, tracking snippets rarely get cleanly uninstalled. A common architectural breakdown we discover during tracking audits is the co-existence of hardcoded Google tag (gtag.js) scripts in the theme header alongside an active Google Tag Manager container. While both tools are built by Google, running them simultaneously without coordination wrecks your analytics.

Instead of clean customer journeys, you get doubled pageviews, artificially depressed bounce rates, split sessions, and conflicting consent commands. Because both scripts report to the same GA4 measurement ID, executive dashboards look vibrant with inflated engagement numbers while underlying campaign attribution collapses.

How duplicate measurement libraries collide in the browser

Both gtag.js and Google Tag Manager rely on the shared window.dataLayer JavaScript array. When hardcoded snippets and GTM operate on the same page, they execute competing configuration commands that race against each other during initial page load.

A typical hardcoded snippet contains an inline script tag that downloads https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX and executes gtag('config', 'G-XXXXXXXXXX'). This immediately triggers an automated page_view event. Meanwhile, your Google Tag Manager container loads its own library, evaluates its internal triggers, and fires a Google tag configured for the exact same Measurement ID.

The result is an instant duplicate hit. When a visitor lands on a single product page, GA4 registers two simultaneous pageviews with identical timestamps. Because GA4 treats two pageviews within milliseconds as an engaged session, your site engagement rate artificially leaps towards ninety-five percent, hiding genuine visitor bounce behaviour.

Here is an illustrative comparison using invented round numbers (not a client result) showing how duplicate tags inflate engagement metrics and distort conversion rates over a typical monthly trading cycle:

Metric ObservedSingle Container BaselineDual gtag + GTM StateDistortion VarianceCommercial Decision Impact
Real Customer Sessions45,000 sessions45,000 sessions0 varianceActual customer footfall is unchanged.
Total Recorded Pageviews110,000 views218,000 views+108,000 phantom viewsPageview counts doubled, corrupting content popularity metrics.
Average Views Per Session2.44 views/session4.84 views/session+2.40 viewsContent engagement artificially inflated, masking drop-offs.
Measured Engagement Rate54% engaged96% engaged+42% artificial boostMarketing believes landing pages perform twice as well as reality.
eCommerce Conversion Rate2.2% conversion1.1% conversion-1.1% apparent declineStore looks like it underperforms industry conversion benchmarks.
Total Recorded Revenue£99,000£99,000£0 varianceCash matches, but session efficiency metrics are ruined.

When conversion rates appear to halve overnight while pageviews double, marketing leaders waste weeks investigating hypothetical website usability flaws that are actually caused by duplicate measurement code.

Diagnostic symptoms that reveal a dual-tag setup

Spotting a dual-tag conflict does not require waiting for monthly reporting anomalies. The conflict leaves clear technical footprints across your network traffic and property settings:

What you observe in GA4 or browser toolsUnderlying technical conflictCommercial damage to marketing decisions
Google Tag Assistant shows two identical Google tags for the same G- Measurement ID.Hardcoded gtag.js exists in the site theme template while GTM also executes a Google tag.Data collection costs rise, event volume quotas are exhausted prematurely, and reporting tables bloat.
Two collect?v=2 network requests with en=page_view fire on every single page navigation.Both the hardcoded inline script and GTM's pageview trigger execute independently on page load.Conversion rates are halved in executive reports, prompting panic changes to high-performing layouts.
User engagement duration remains near zero seconds across thousands of engaged sessions.Competing config calls overwrite session start parameters, breaking GA4 engagement calculation algorithms.Marketing teams cannot identify which blog articles or landing pages genuinely retain qualified prospects.
Consent Mode default settings are ignored, sending full tracking pings before cookie consent.The hardcoded gtag.js script lacks consent default commands and fires prior to the CMP initialization.Severe regulatory compliance risk under UK privacy laws, exposing the company to regulatory scrutiny.

Safely consolidating tracking into Google Tag Manager

Resolving this conflict requires consolidating all measurement under a single governance structure: Google Tag Manager. Leaving hardcoded scripts in place while running GTM undermines container hygiene and creates continuous maintenance liabilities.

The audit begins by searching your website templates, header injection plugins, and theme files for any occurrence of googletagmanager.com/gtag/js or function gtag(). In platforms like Shopify, WooCommerce, or WordPress, these snippets are often left behind by legacy Google app integrations or abandoned header plugins.

Before removing the hardcoded script, verify that your GTM container contains an identical Google tag configuration mapped to your Measurement ID, with proper Consent Mode triggers attached. Once the container is verified in GTM Preview mode, remove the hardcoded script from your codebase in a single coordinated deployment.

As we discussed in our teardown on how bloated Custom HTML tags in Google Tag Manager drag down mobile Core Web Vitals, cleaning up redundant scripts directly benefits site speed. In our analysis of why GA4's automatic form_submit event counts site searches, logins and failed clicks as leads, we explore how default event listeners create further reporting distortion if left unmonitored.

Frequently asked questions

Can I run both hardcoded gtag.js and Google Tag Manager at the same time?

While a website will technically function with both, running hardcoded gtag.js alongside GTM for the same Google Analytics property causes duplicate pageviews, corrupted session engagement, and conflicting consent commands. All Google measurement tags should be consolidated inside Google Tag Manager for reliable governance.

How do I tell if a pageview came from GTM or hardcoded gtag.js?

Open Google Chrome Developer Tools, navigate to the Network tab, and filter by collect?v=2. Look at the Initiator column for each request. Requests initiated by gtm.js originate from your Tag Manager container, whereas requests initiated directly by gtag/js originate from inline theme scripts.

Does removing the hardcoded gtag.js script delete historical data in GA4?

No. Historical data in GA4 is permanent and will not be altered or deleted by modifying tracking scripts. However, removing the duplicate script will normalize future metrics, causing recorded pageviews to drop and conversion rates to return to their true baseline levels.

Untangling duplicate tracking across your web properties

If your analytics reports show suspicious engagement metrics, duplicate pageviews, or conflicting Google tags, we can help. Through our Google Tag Manager consultancy, cookie consent and tracking repair, and eCommerce tracking service, we audit your codebase, eradicate duplicate scripts, and establish clean, reliable measurement. You can review our full range of technical capabilities under our tracking and reporting consultancy.