Skip to main content
TagManifest /Docs Dashboard

Custom HTML using gtag() instead of native

Custom HTML contains gtag() calls instead of using native GA4 event tags, losing consent integration and debugging.

On this page 6

Summary

  • rule_id — ga4-custom-html-gtag
  • purpose — Detect Custom HTML tags calling gtag() instead of native GA4 event tags in GTM (Google Tag Manager)
  • effect — Container bypasses GTM's consent framework and loses built-in debugging support
  • layer — container
  • reversibility — non-destructive

What fires this

The rule inspects all active Custom HTML tags for any gtag( call in the tag code. A tag is flagged when at least one gtag() call is not an Ads conversion or Floodlight call. The rule excludes calls matching gtag('event','conversion',...) with send_to: 'AW-' or send_to: 'DC-' — those are Google Ads Conversion Tracking and Floodlight, which have their own native GTM templates. The rule is conservative: if a tag contains any non-Ads gtag() call alongside conversion calls, the tag is still flagged. Paused tags are excluded.

Why it matters

Native GA4 Event tags in GTM connect directly to GTM's consent state model. Custom HTML gtag() calls do not. When consent is withdrawn, a native tag stops firing automatically; a Custom HTML tag continues unless the developer adds manual consent checks. Custom HTML tags also load the gtag.js script independently, which can conflict with an existing Global Site Tag and create duplicate hits. Native tags surface in GTM's Tag Assistant and Preview mode with parameter-level detail. gtag() in Custom HTML appears as an opaque block.

Before / after

<script>
  gtag('event', 'purchase', {
    transaction_id: order.id,
    value: order.total,
    currency: 'USD'
  });
</script>
GTM tag type: GA4 Event
Tag name: GA4 — Purchase
Configuration tag: [GA4 Config tag]
Event name: purchase
Event parameters:
  transaction_id → {{DL - order.id}}
  value          → {{DL - order.total}}
  currency       → USD
Consent settings: inherited from GA4 Config tag

Remediation

  1. Open GTM and find each flagged Custom HTML tag.
  2. Identify which GA4 event the gtag() call is sending.
  3. Create a new GA4 Event tag of the same name, linked to your existing GA4 Configuration tag.
  4. Map each parameter from the gtag() call to GTM variables in the new tag.
  5. Set the same firing triggers as the Custom HTML tag.
  6. Test the new tag in GTM Preview mode and confirm hits appear in GA4 DebugView.
  7. Pause or delete the Custom HTML tag after confirming parity.

Metadata

Severity
medium
Tier
optimization
Category
ga4
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":"ga4-custom-html-gtag","url":"https://example.com"}'