Skip to content

New rule: analytics/duplicate-tags - the same analytics tag installed more than once on a page #1691

Closed

Description

@nc9

Problem

When the same analytics tag is loaded twice on a page, every pageview and event is counted twice. It usually happens when a tag is added in the site template and again through a tag manager or a plugin. analytics/gtm-present only reports which platforms are present, and it deduplicates that list, so a double install passes.

Proposal

A page rule, analytics/duplicate-tags, that warns when one page loads the same tag more than once:

  • Google Analytics 4: the same measurement ID (G-...) configured more than once.
  • Google Tag Manager: the same container ID (GTM-...) loaded more than once.
  • The other platforms analytics/gtm-present detects (Plausible, Fathom, Matomo, Segment, Mixpanel, Amplitude, Heap, Hotjar, Microsoft Clarity): the same loader with the same site or project ID included more than once.

Acceptance Criteria

  • A page that loads the same GA4 measurement ID twice gets a warning naming the ID and the number of times it appears.
  • A page that loads the same GTM container ID twice gets a warning naming the container ID.
  • A page that includes the same loader with the same site or project ID twice, for each of the other listed platforms, gets a warning naming the platform and the ID.
  • Two different IDs for the same platform on one page are not flagged.
  • The standard GTM pair of one script and one noscript frame for the same container counts as one install.
  • A GA4 loader script plus its own config call for the same ID counts as one install.
  • A preload or preconnect hint for a tag's host is not counted as an install.
  • Each platform has a fixture with a single install that passes and a double install that warns.
  • IDs in the finding are shown as they appear in the page. No request is made to any analytics vendor.
  • When the same duplicate appears on many pages, the report groups it as one issue with the affected pages listed.
  • The same input gives the same result on every run.
  • The rule has a docs page under docs/rules/analytics/ and appears in the rule catalog and counts.

Activity

  1. added
    enhancement
    size: M
    rules
    on Nov 11, 2026
  2. added theissue type on Nov 11, 2026
  3. nc9 commented on Nov 11, 2026

    @nc9
    ContributorAuthor

    Shipped in v0.0.177 via 1a9887b (fix(rules): analytics/duplicate-tags reads every vendor loader as a URL, id in any case; docs: Security rule count #1691).

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions