Skip to main content
TagManifest /Docs Dashboard

All Pages trigger with URL-specific code

Tags fire on every page but contain URL-checking logic. This means the tag loads, parses, and executes on every page just to check if it should run. Use a targeted trigger instead.

On this page 6

Summary

  • rule_id — all-pages-url-specific
  • purpose — Detect Custom HTML tags that fire on All Pages but contain URL-checking logic in their code
  • effect — Tag loads and executes on every page view, even pages where it immediately exits
  • layer — container
  • reversibility — non-destructive

What fires this

The rule inspects active Custom HTML tags whose firingTriggerIds includes the All Pages built-in trigger ID (2147479553). It then tests the tag code against a pattern matching location.href, location.pathname, window.location, document.URL, or hostname. A tag must match both conditions to be flagged. Paused tags are excluded. This rule is suppressed on public-endpoint scans because Google's compilation step transforms the All Pages trigger ID — it fires reliably only against JSON container exports.

Why it matters

GTM loads and executes the full tag on every page before the tag's own URL check runs. On a site with 20 pages, a tag intended for one URL fires 19 times needlessly. Moving the URL condition into a GTM trigger filter prevents the tag from loading at all on irrelevant pages. The performance cost scales with tag weight — large Custom HTML tags with third-party script calls waste the most. The pattern is common in legacy containers where inline if statements replaced proper trigger configuration.

Before / after

// Tag fires on All Pages trigger
// URL gate lives inside the tag code
if (!location.pathname.startsWith('/checkout/')) return

// checkout-specific tracking code below
dataLayer.push({ event: 'checkout_view' })
Trigger type: Page View — Some Pages
Condition: Page Path starts with /checkout

Tag code (no URL check needed):
dataLayer.push({ event: 'checkout_view' })

Remediation

  1. Open the flagged Custom HTML tag in GTM.
  2. Identify the URL pattern in the JavaScript (e.g., location.pathname.startsWith('/checkout/')).
  3. Create a Page View — Some Pages trigger with a filter matching that URL pattern.
  4. Remove the All Pages trigger from the tag and assign the new URL-specific trigger.
  5. Delete the URL-checking code from the tag body — the trigger now handles that condition.
  6. Preview in GTM debug mode and confirm the tag fires only on the intended pages.
  7. Publish the container.

Metadata

Severity
medium
Tier
optimization
Category
performance
Layer
container
Version
1
Effort
2hr (about 2 hours)
Reversibility
non-destructive

See also

Examples

Evaluate
curl https://developer.tagmanifest.com/v1/evaluate-rule \
  -H "Authorization: Bearer $TM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"rule_id":"all-pages-url-specific","url":"https://example.com"}'