How to Fix Duplicate Analytics Tags (Google Tag Loaded Twice)

This check flags pages where the same Google tag ID (for example G-ABC123XYZ or AW-123456789) is loaded by more than one gtag.js script. By the end of this guide you will have found every place the tag is injected, picked one loading method, removed the extras, and confirmed that each ID loads only once per page.

By Updated ⏱ 20-30 minutes🎯 Beginner● Medium impactTechnical
Illustration: Duplicate analytics tags fix guide
TECHNICAL · FIX GUIDE Duplicate analytics tags IMPACTEFFORT TIME20-30 minutes LEVELBeginner

Why it matters

When the same measurement ID loads twice, GA4 often records two page_view events per visit. Pageviews inflate, bounce and engagement rates are skewed, and conversions can be counted twice, which misleads Google Ads Smart Bidding and any reporting built on GA4 data. The extra script also adds an avoidable network request and JavaScript execution, which slightly affects page speed.

The fix is usually a single deleted snippet or a toggle in a plugin or integration.

✕BeforePage source contains <scriptsrc="https://www.googletagmanager.com/gtag/js?id=G-ABC123XYZ">twice: once in the theme header and✓AfterEach page loads gtag/js?id=G-ABC123XYZexactly once, either through GTM orone hardcoded snippet, and GA4 shows

What you need

Admin access to your CMS, theme files or site code
Access to your Google Tag Manager container (if you use one)
Your GA4 Measurement ID (GA4 > Admin > Data streams > your web stream)
Chrome with DevTools, or a terminal with curl

Step-by-step fix

1

Confirm which IDs are duplicated

Open a flagged page and check how many times each Google tag ID is requested. Run the command below against the raw HTML; any count above 1 is a duplicate. Then open the page in Chrome, press F12, and run the console snippet, which also catches scripts injected by JavaScript after the page loads.

text
curl -s https://www.example.com/ | grep -o 'googletagmanager.com/gtag/js?id=[A-Za-z0-9-]*' | sort | uniq -c

// Chrome DevTools console:
const ids=[...document.querySelectorAll('script[src*="googletagmanager.com/gtag/js"]')].map(s=>new URL(s.src).searchParams.get('id'));
const counts=ids.reduce((a,id)=>(a[id]=(a[id]||0)+1,a),{});
console.table(counts);
Pro tip: Test a few page types (home, product, blog post, checkout). Duplicates often come from a template used only on some pages.
2

List every place a Google tag is installed

Duplicates almost always come from two installation methods running together. Check each of these:

  • Hardcoded snippet in the theme or layout file (header.php, theme.liquid, _document.tsx, base template)
  • A CMS integration field (Shopify Google & YouTube app, Wix Marketing Integrations, Webflow Google Analytics field)
  • An analytics plugin (Site Kit by Google, MonsterInsights, GA4WP, WPCode snippets)
  • A Google tag inside your GTM container that uses the same ID
  • Third-party scripts like cookie banners or page builders that offer their own GA field
Pro tip: In DevTools, open the Network tab, filter by "gtag/js", reload, and click each request. The Initiator column shows which file or script injected it.
3

Choose one loading method

Pick a single source of truth for each ID. js snippet. js snippet in your site-wide head and disable analytics in all plugins and integrations.

Write down the decision so future plugin installs do not reintroduce the tag.

Pro tip: GTM is usually the better choice when marketing teams add tags often, because changes happen in one interface without editing theme code.
4

Remove the extra snippets

Delete or disable every installation except the one you chose. js script tag and its inline config block. For plugins and integrations, turn off the analytics option rather than just clearing the ID field, since some keep injecting an empty or cached tag.

Clear any page cache or CDN cache afterwards.

html
<!-- Remove this whole block if GA4 is loaded through GTM -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABC123XYZ"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-ABC123XYZ');
</script>
Pro tip: Before deleting, copy any custom config parameters (like send_page_view: false or user_id) so you can recreate them in the remaining setup.
5

Combine multiple IDs into one snippet

If you run several destinations (GA4 plus Google Ads), you only need one gtag.js script. Load it once with your primary ID and add a config line for each extra ID. In GTM, use one Google tag and add the other IDs under the tag's destination settings, or separate tags that do not duplicate an ID already loaded.

html
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABC123XYZ"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-ABC123XYZ');
  gtag('config', 'AW-123456789');
</script>
6

Check GTM for duplicate Google tags

In Google Tag Manager, go to Tags and filter by type Google tag (and older GA4 Configuration tags). Make sure each Tag ID appears in only one tag that fires on All Pages or Initialization - All Pages. If two tags share an ID, pause or delete one, then click Submit and Publish.

Pro tip: Also check for a second GTM container on the site. Two containers that both load the same Google tag cause the same duplicate.
7

Verify the fix on live pages

Reload the flagged pages with cache bypassed (Ctrl+Shift+R) and rerun the curl command and console snippet from step 1; each ID should show a count of 1. Open Tag Assistant (tagassistant.google.com), connect to https://www.example.com/, and confirm one page_view per page load. Then rerun the audit to clear the warning.

text
curl -s -H 'Cache-Control: no-cache' https://www.example.com/ | grep -o 'gtag/js?id=[A-Za-z0-9-]*' | sort | uniq -c
Pro tip: Compare GA4 pageviews per session for the week before and after the fix. A drop of roughly half confirms the double counting is gone; annotate the date in your reports.

Platform-specific notes

WordPress

The usual cause is a theme or WPCode/Insert Headers and Footers snippet plus Site Kit or MonsterInsights. In Site Kit, go to Site Kit > Settings > Connected Services > Analytics and turn off tag placement if you load GA4 elsewhere; Site Kit also detects an existing tag and can skip inserting its own. Check Appearance > Theme File Editor > header.php and your child theme too, then purge caching plugins.

Shopify

The Google & YouTube app installs GA4 through Shopify's pixel system. If theme.liquid (Online Store > Themes > Edit code) or a custom pixel under Settings > Customer events also loads the same G- ID, remove the manual one. Checkout pages only run pixels, so keep GA4 in one place that covers both storefront and checkout.

Wix

Wix adds GA4 via Settings > Marketing Integrations > Google Analytics. If you also pasted the gtag snippet under Settings > Custom Code, or GTM via Marketing Integrations, delete the duplicate so only one method loads the ID.

Webflow

Check Site settings > Apps & integrations > Google Analytics (Measurement ID field) and Site settings > Custom code > Head code, plus page-level custom code. Keep one, clear the other, then republish the site.

Next.js

Use either @next/third-parties GoogleAnalytics/GoogleTagManager components or a manual next/script tag in the root layout, not both. Place it once in app/layout.tsx (or pages/_app.tsx), never in individual pages or components that render repeatedly.

Check that it worked

✅ How to verify

  • Run the curl or console snippet on several page types and confirm each gtag/js?id= value appears once.
  • In DevTools Network tab, filter by "gtag/js" and confirm one request per ID after a hard reload.
  • Use Tag Assistant or GA4 Admin > DebugView to confirm a single page_view event per page load.
  • Rerun the site audit and confirm the duplicate analytics warning no longer appears.

⚠️ Common mistakes

  • Deleting the GA4 ID in a plugin field but leaving the plugin's tracking option enabled, so it still outputs a snippet.
  • Removing the hardcoded tag but forgetting to purge the page cache or CDN, so old HTML with both tags keeps being served.
  • Loading GTM and a hardcoded gtag.js for the same G- ID because the GTM Google tag was added later and the old snippet was never removed.
  • Placing the tag in a component or page template instead of the site-wide layout, so it loads once per section on some pages.

Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.

Check my site free

FAQ

How do I know if Google Analytics is installed twice?

View the page source or DevTools Network tab and search for "gtag/js?id=". If the same ID appears more than once, it is installed twice. In GA4, unusually high pageviews per session or two page_view events per load in DebugView are also signs.

Does GA4 deduplicate if the tag is loaded twice?

Not reliably. gtag.js has some protection against repeat config calls, but separate installations (for example GTM plus a hardcoded snippet) commonly send duplicate page_view and conversion events, so you should load each ID once.

Can I have GA4 and Google Ads tags on the same page?

Yes. Different IDs are fine. Load gtag.js once and add a gtag('config', ...) line for each ID, or manage them in one GTM container. Only the same ID loaded more than once is a problem.

Will removing a duplicate tag affect my historical data?

No. Past data stays as recorded. Your metrics will drop to accurate levels from the fix date onward, so add an annotation in your reporting to explain the change in trend.