# Event names follow a consistent naming convention

- **Pattern:** `ab-001714` (`marketing-analytics.data-quality.event-naming-convention`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001714
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001714)

## Why it matters

Mixed analytics event naming conventions — `camelCase` alongside `snake_case` alongside `PascalCase` — cause silent query failures in analytics dashboards. A funnel that joins `buttonClicked` with `button_clicked` misses events and produces artificially low conversion numbers. This is an observability issue (iso-25010:2011 Maintainability): when event names are inconsistent, adding a new tracking point requires reading existing code to guess which convention applies, and mistakes go undetected until conversion data looks wrong in production.

## Severity rationale

Low because inconsistent naming degrades analytics data quality and developer experience without creating a security or availability risk.

## Remediation

Standardize on `snake_case` (the GA4 and PostHog default) and define all event names as typed constants in `lib/analytics-events.ts`:

```ts
// lib/analytics-events.ts
export const ANALYTICS_EVENTS = {
  CTA_CLICKED: 'cta_clicked',
  FORM_SUBMITTED: 'form_submitted',
  FORM_ABANDONED: 'form_abandoned',
  PAGE_VIEWED: 'page_viewed',
} as const

// Usage:
analytics.track(ANALYTICS_EVENTS.CTA_CLICKED, { location: 'hero' })
```

Import from this file everywhere — typos become compile errors and the full event catalog is in one place. Rename existing events in your analytics platform's UI to match; most platforms support event aliases during migration.

## Detection

- **ID:** `event-naming-convention`
- **Severity:** `low`
- **What to look for:** Consistent event naming makes analytics data queryable and maintainable. Check for:
  - Mixed naming styles: `camelCase` events (`buttonClicked`) mixed with `snake_case` events (`button_clicked`) mixed with `PascalCase` events (`ButtonClicked`)
  - Events with spaces in names (some platforms don't support this)
  - Very generic event names (`click`, `event`, `action`) mixed with specific names
  - Past tense vs. present tense inconsistency (`button_clicked` vs. `button_click`)
- **Pass criteria:** Enumerate all unique analytics event names across the codebase. All analytics event calls use a consistent naming style (all snake_case, all camelCase, or all in line with the chosen platform's conventions). Fewer than 2 naming style deviations are acceptable out of the total count.
- **Fail criteria:** 3 or more different naming styles are used across event calls, making the analytics data difficult to query consistently. Quote the actual event names that deviate from the primary pattern.
- **Skip (N/A) when:** No analytics event calls found (beyond page views). Skip if fewer than 5 event calls exist (too few to establish a pattern).
- **Detail on fail:** `"Mixed event naming found: 'buttonClicked' (camelCase), 'form_submit' (snake_case), 'PageView' (PascalCase). Inconsistent naming makes analytics queries fragile and error-prone."`
- **Remediation:** Standardize on one naming convention for event names. The GA4 and PostHog recommendation is `snake_case` (e.g., `cta_clicked`, `form_submitted`, `page_viewed`). Once chosen, document it:

  ```ts
  // lib/analytics-events.ts — define all event names as constants
  export const ANALYTICS_EVENTS = {
    CTA_CLICKED: 'cta_clicked',
    FORM_SUBMITTED: 'form_submitted',
    FORM_ABANDONED: 'form_abandoned',
    SCROLL_DEPTH: 'scroll_depth',
  } as const
  ```

  Using typed constants prevents typos and makes future event name changes trivial.

## External references

- iso-25010 maintainability

Taxons: observability, code-quality

HTML version: https://auditbuffet.com/patterns/ab-001714
