Skip to content

About

Claude Code skill that audits, installs, and fixes GA4 tracking so the data actually drives conversions

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forge-analytics

A Claude Code skill that audits, installs, and fixes Google Analytics 4 tracking on a website — so the data actually tells you what to change.

Most GA4 installs measure page views and nothing else. You end up knowing how many people visited, but not which button they clicked, which form they abandoned, or whether they called instead. This skill installs the event layer that answers those questions, and refuses to ship the things that quietly poison a property: duplicate events, PII in parameters, and dev traffic in production reports.

Install

git clone https://github.com/RamzanReshi/forge-analytics.git ~/.claude/skills/forge-analytics

Then in Claude Code:

/forge-analytics

Or just describe the task — "audit my analytics", "set up GA4 with G-XXXXXXXXXX", "am I tracking the right things" — and it triggers on its own.

Three modes

Mode When Output
Audit "check my analytics", no tag given Report card, plain English. No code changes.
Install / Fix "set up GA4", tag given, or audit found gaps Helper file, wired events, ANALYTICS.md
Verify "are events firing" Live data check, conversion grading

Unclear requests default to Audit — it is read-only and tells the other modes what to do.

What gets tracked

Conversions (you mark these as key events in GA4): generate_lead · phone_click · whatsapp_click · email_click · booking_click

Engagement: cta_click · form_start · form_error · section_view · scroll_depth · nav_click · outbound_click · menu_toggle · video_play · faq_open · file_download

Names are static snake_case and identical across projects, so one GA4 report layout works for every site you build. Variation lives in parameters — button_text, section_name, form_name, location, link_domain, cta_variant — never in the event name, which would fragment reports into hundreds of useless rows.

The goal is being able to answer five questions:

  1. Which page or section produces the most contacts?
  2. Which CTA copy and placement converts best?
  3. How many start the form vs finish it, and which field loses them?
  4. Which contact channel do people actually prefer?
  5. Where do visitors stop reading?

What it refuses to do

No PII, ever. No emails, phone numbers, names, addresses, or message bodies. The helper scrubs email- and phone-shaped parameter values as a backstop even if a call site gets it wrong. Tracks that a form was submitted, never its contents. This is a GA4 ToS violation and a property-deletion risk, not a style preference.

Production only. Gating is a hostname allowlist, not a preview-URL blocklist — an unknown host never sends data. Disabled on localhost, private LAN ranges, *.local, preview deploys, dev builds, and test runners. A blocklist always falls behind new preview URL patterns; an allowlist fails safe.

No duplicate events. Structural guards, not hope: once-only keys for form starts, section views, and scroll thresholds; unobserve after firing; capture-phase delegation that does not double-count clicks already tracked by a component's own onClick.

No fake page views. On single-page anchor-scroll sites there are no route changes, and firing page_view on anchor scroll inflates sessions and destroys bounce-rate meaning. The skill detects this and uses section_view instead. On real routers it sets send_page_view: false and fires manually, so the initial view is not double-counted.

What you still do yourself

Two things live in the GA4 UI and cannot be set from code. The skill outputs both as a checklist:

  1. Mark the conversion events as key events. Unmarked, they never appear in conversion reports and cannot be imported into Google Ads.
  2. Register the custom dimensions. Unregistered parameters are collected correctly but never appear in reports — the most common reason a technically correct install still produces useless data.

Contents

SKILL.md                        mode routing, workflow, hard rules
references/event-taxonomy.md    events, parameters, what each answers
references/implementation.md    gating, route changes, dedupe, testing
references/reporting.md         plain-English summary format
scripts/audit_analytics.py      codebase scanner (stdlib only, no deps)
templates/analytics.ts          helper starter, typechecks under strict
templates/ANALYTICS.md          per-project documentation template

The scanner detects measurement IDs, existing events, competing vendors (GTM, Plausible, PostHog, Meta Pixel, and others), every tel:/wa.me/mailto:/booking/form surface worth tracking, and reliability flags: PII risk, dynamic event names, query strings in page_path, missing production gating, duplicate gtag snippets, legacy Universal Analytics.

Status

The scanner and the helper template are tested: the scanner runs clean against real production sites and correctly flagged two genuine bugs on the first site it was pointed at, and the template typechecks under strict with 26 unit cases passing on the gating and PII-scrub logic.

A full Install-mode run start-to-finish, with events confirmed landing in GA4 Realtime, has not been done yet. Treat the timing estimates as estimates.

License

MIT

About

Claude Code skill that audits, installs, and fixes GA4 tracking so the data actually drives conversions

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages