# Umami Admin Pages Exclusion ## Changes Made Updated the Umami tracking hook to **completely exclude all admin pages** from tracking. ### What's Excluded The following routes are excluded from Umami tracking: - `/admin` - Admin dashboard - `/admin/*` - All admin sub-pages (articles, matches, settings, analytics, etc.) - `/login` - Login page - `/setup` - Initial setup page ### Implementation **File: `frontend/src/hooks/useUmami.ts`** Added `isAdminRoute()` helper function: ```typescript const isAdminRoute = (pathname: string) => { return pathname.startsWith('/admin') || pathname === '/login' || pathname === '/setup'; }; ``` **Three levels of exclusion:** 1. **Script Loading** - Umami script is not loaded on admin pages ```typescript // Don't load Umami for admin pages if (isAdminRoute(location.pathname)) { console.log('Umami tracking disabled for admin pages'); return; } ``` 2. **Page View Tracking** - Admin page views are not sent to Umami ```typescript if (location.pathname && !isAdminRoute(location.pathname)) { trackAnalyticsEvent({ ... }); } ``` 3. **Custom Events** - Events triggered on admin pages are not sent to Umami ```typescript if (isAdminRoute(location.pathname)) { return; // Skip tracking } ``` ### Why This Matters **Benefits:** - ✅ **Clean analytics** - Only public-facing pages in Umami dashboard - ✅ **Better performance** - No tracking overhead in admin panel - ✅ **Privacy** - Admin activity not tracked - ✅ **Accurate metrics** - Real visitor data without admin noise **What still tracks admin pages:** - Local analytics database (powers `/admin` dashboard widgets) - This is intentional - you want to see which admins are active ### Testing **Before (admin pages were tracked):** ``` Umami Dashboard: /admin - 5 views /admin/articles - 3 views /admin/settings - 2 views / - 10 views ``` **After (only public pages tracked):** ``` Umami Dashboard: / - 10 views /articles - 8 views /zapasy - 6 views (no /admin routes) ``` ### How to Verify 1. **Open browser console** 2. **Visit a public page** (e.g., `/`) - Console shows: `Umami tracking loaded` - Script tag exists: `` 3. **Visit admin page** (e.g., `/admin`) - Console shows: `Umami tracking disabled for admin pages` - No Umami script in `` - No tracking requests to Umami server 4. **Check Umami dashboard** - No `/admin` routes in "Top Pages" - Only public pages visible ### Local Analytics Still Work The local analytics database (`visitor_events` table) continues to track **all pages** including admin: - Powers the widgets on `/admin` dashboard - Used for internal monitoring - Not sent to Umami **This is intentional!** You have: - **Public analytics** → Umami (for website visitors) - **Internal analytics** → Local DB (for admin monitoring) ### Console Output **Public page (`/`):** ``` Umami tracking loaded ``` **Admin page (`/admin`):** ``` Umami tracking disabled for admin pages ``` **Switching from admin to public:** ``` // On /admin Umami tracking disabled for admin pages // Navigate to / Umami tracking loaded ``` ### Edge Cases Handled 1. **Direct navigation to admin** - Script never loads 2. **Navigation from public to admin** - Tracking stops 3. **Navigation from admin to public** - Script loads on public page 4. **Custom events in admin** - Silently ignored (not sent to Umami) ### Production Deployment No special configuration needed! The exclusion works automatically based on URL paths. With Cloudflare Tunnel: - `https://fotbalklub.cz/` → Tracked ✅ - `https://fotbalklub.cz/admin` → Not tracked ❌ - `https://fotbalklub.cz/zapasy` → Tracked ✅ Perfect! 🎉 ## Summary Admin pages are now **completely excluded** from Umami tracking at all levels: - No script loading - No page view tracking - No event tracking Your Umami analytics will show **only real visitor activity** on public pages!