# GA4 Event Tracker (Chrome Extension)

A Chrome Extension (Manifest V3) that injects Google Analytics 4 tracking code into every visited webpage and provides a sleek dark-mode terminal-style HUD popup showing real-time event counts and status.

## Features

- Injects the GA4 snippet (`G-RN41M36MWL`) into every page automatically
- Dark-mode terminal HUD popup with live event counter
- Persists event counts per tab using Chrome Storage API
- Reset button and keyboard shortcut (Ctrl+R) to zero out counts
- Service worker background script for reliable content script injection

## Installation (Developer Mode)

1. Open Chrome and navigate to `chrome://extensions`
2. Enable "Developer mode" (toggle in top-right)
3. Click "Load unpacked"
4. Select the `extension/` directory
5. The GA4 Event Tracker icon will appear in the toolbar

## Usage

1. Click the extension icon to open the terminal HUD popup
2. Browse any webpage — GA4 events are tracked automatically
3. The popup displays:
   - **events recorded**: running count of GA4 events on the current page
   - **last event**: name of the most recent event
   - **status**: connection status (`active`, `scanning`, `inactive`)
4. Click **reset** (or press Ctrl+R) to clear the counter

## Packaging for Chrome Web Store

```bash
# From the project root, create the zip:
cd extension && zip -r ../ga4-event-tracker.zip . -x "*.DS_Store"
```

Upload `ga4-event-tracker.zip` to the [Chrome Web Store Developer Dashboard](https://chrome.google.com/webstore/devconsole).

## Files

| File | Purpose |
|------|---------|
| `manifest.json` | Extension manifest (MV3) |
| `background.js` | Service worker — registers content scripts, relays events |
| `contentScript.js` | Injects GA4 snippet, monitors gtag() calls |
| `popup.html` | Terminal HUD popup markup |
| `popup.css` | Dark terminal theme |
| `popup.js` | Popup logic — queries event counts, reset |

## Permissions

- `scripting` — inject content scripts
- `storage` — persist event counts
- `activeTab` — access current tab for popup
- `notifications` — (reserved for future use)

## License

MIT
