Event names with invalid characters
Event names contain spaces, hyphens, or start with a number. GA4 will reject or silently rename these events.
Summary
- rule_id —
ga4-event-name-invalid-chars - purpose — Detect GA4 event tags whose static event names contain characters outside the GA4-allowed set
- effect — GA4 rejects or silently renames events with invalid names, making them unreliable measurement points
- layer — container
- reversibility — non-destructive
What fires this
The rule calls getGA4EventTags(data) to collect all GA4 event tags, then tests each static event name against the allowlist regex ^[a-zA-Z][a-zA-Z0-9_]*$. A tag fires this rule when its name fails that test. Tags whose event name contains {{ are excluded — GTM variable references cannot be statically evaluated. The allowlist catches the full range of invalid characters: spaces, hyphens, commas, slashes, parentheses, and periods, not only the most common offenders.
Why it matters
GA4 enforces strict naming rules at ingest. An event name must start with a letter and contain only letters, numbers, and underscores. Names that violate these rules are silently dropped or routed to an unassigned bucket — GA4 provides no client-side error when this happens. Hyphens are the most common cause: GTM accepts cta-click without warning, but GA4 treats it as invalid. Because the failure is silent, invalid-name events can go undetected through QA and only surface as gaps in reports.
Before / after
GA4 Event tag
Event name: cta-click
GA4 Event tag
Event name: cta_click
Remediation
- Open each flagged GA4 event tag and note the exact event name.
- Identify which characters are invalid (hyphens, spaces, leading digits, or other non-alphanumeric characters).
- Rename the event using only letters, numbers, and underscores, starting with a letter (e.g.,
cta-click→cta_click,Form Submit→form_submit). - Update any Custom Event triggers that reference the old event name to match the corrected name.
- If the event is registered as a conversion in GA4, update the conversion definition to use the new name.
- Publish the container and confirm events arrive with valid names in GA4 DebugView.
Metadata
- Severity
- high
- Tier
- warning
- Category
- ga4
- Layer
- container
- Version
- 1
- Effort
15min(about 15 minutes)- Reversibility
- non-destructive
See also
- GA4 rules — other rules in this category
- Health score — how this rule contributes to the score
- Rules catalog — browse all rules
Examples
curl https://developer.tagmanifest.com/v1/evaluate-rule \
-H "Authorization: Bearer $TM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"rule_id":"ga4-event-name-invalid-chars","url":"https://example.com"}'
User: Run ga4-event-name-invalid-chars on https://example.com
# Tool call
{
"tool": "evaluate_rule",
"arguments": {
"rule_id": "ga4-event-name-invalid-chars",
"url": "https://example.com"
}
}