@extends('layouts.user_type.auth') @section('pageTitle', 'Visitor Analytics') @section('pageSub', 'Track real-time traffic, page views, visitor devices, browsers and daily trends.') @section('pageActions') Export CSV @if(request()->hasAny(['search', 'ip_address', 'page_url', 'date_preset', 'from_date', 'to_date', 'visit_date', 'device', 'browser', 'os'])) Clear Filters @endif @endsection @section('visitorTracker') @include('components.alert') @php $currentPreset = request('date_preset', ''); $totalSample = max(1, array_sum($deviceBreakdown)); $desktopPct = round(($deviceBreakdown['Desktop'] ?? 0) * 100 / $totalSample); $mobilePct = round(($deviceBreakdown['Mobile'] ?? 0) * 100 / $totalSample); $botPct = round(($deviceBreakdown['Bot'] ?? 0) * 100 / $totalSample); $activeFiltersCount = collect(['search', 'ip_address', 'page_url', 'date_preset', 'from_date', 'to_date', 'visit_date', 'device', 'browser', 'os'])->filter(fn($k) => request()->filled($k))->count(); @endphp {{-- ==================== DASHBOARD KPIS ==================== --}}
Today's Visitors
{{ number_format($stats['today']) }}
@if($stats['yesterday'] > 0) @php $diff = $stats['today'] - $stats['yesterday']; @endphp {{ abs($diff) }} vs yesterday @else {{ $stats['yesterday'] }} yesterday @endif
Last 7 Days
{{ number_format($stats['last_7_days']) }}
Avg {{ round($stats['last_7_days'] / 7, 1) }} visitors / day
Last 30 Days
{{ number_format($stats['last_30_days']) }}
{{ number_format($stats['total']) }} all-time total
Unique IP Addresses
{{ number_format($stats['unique_ips']) }}
Distinct individual clients
Device Distribution
{{ $desktopPct }}% / {{ $mobilePct }}%
{{ $deviceBreakdown['Desktop'] ?? 0 }} desktop · {{ $deviceBreakdown['Mobile'] ?? 0 }} mobile
{{-- ==================== DASHBOARD CHARTS & BREAKDOWNS ==================== --}}
{{-- 14-Day Traffic Trend --}}
14-Day Traffic Trend
Daily visitors to your website over the last two weeks.
Peak: {{ $maxChartVal }} / day
Hover over bars to see daily details. Dark bar indicates today. Total 14d: {{ $chart->sum('n') }} visits
{{-- Top Pages & System Breakdown --}}
Top Pages & Platforms
Most requested paths and visitor technology stack.
{{-- Top Pages List --}}
Most Visited Pages
@if ($topPages->isEmpty())
No page tracking recorded yet.
@else
@php $maxPageViews = max(1, $topPages->max('total')); @endphp @foreach ($topPages as $tp) @php $path = parse_url((string) $tp->page_url, PHP_URL_PATH) ?: '/'; $pctPage = round(($tp->total / $maxPageViews) * 100); @endphp @endforeach
@endif
{{-- Browsers & OS Badges --}}
Browsers & Operating Systems
@foreach (array_slice($browserBreakdown, 0, 4, true) as $bName => $bCount) @php $bPct = round(($bCount / $totalSample) * 100); @endphp {{ $bName }} {{ $bPct }}% @endforeach @foreach (array_slice($osBreakdown, 0, 4, true) as $osName => $osCount) @php $osPct = round(($osCount / $totalSample) * 100); @endphp {{ $osName }} {{ $osPct }}% @endforeach
{{-- ==================== ADVANCED FILTER TOOLBAR ==================== --}}
Advanced Search & Filters
Filter visitor traffic by date range, device type, browser, OS, page or IP.
@if ($activeFiltersCount > 0) {{ $activeFiltersCount }} active {{ \Illuminate\Support\Str::plural('filter', $activeFiltersCount) }} Reset all @endif
{{-- Quick Date Preset Strip --}}
Quick Dates:
{{-- Filter Form --}}
@if(request('date_preset')) @endif
{{-- General Search --}}
{{-- Custom Date From --}}
{{-- Custom Date To --}}
{{-- Device --}}
{{-- Browser --}}
{{-- OS --}}
{{-- Page URL --}}
@foreach($filterPages as $p)
{{-- Per Page --}}
Clear All
Filtered: {{ number_format($visitors->total()) }} records
{{-- ==================== VISITOR LOG TABLE ==================== --}}
Detailed Visit Logs
Real-time breakdown of each visitor hit, platform, page and timestamp.
Showing {{ $visitors->firstItem() ?? 0 }}–{{ $visitors->lastItem() ?? 0 }} of {{ number_format($visitors->total()) }}
@forelse ($visitors as $index => $visitor) @php $vtUa = (string) $visitor->user_agent; $vtBot = (bool) preg_match('/bot|crawl|spider/i', $vtUa); $vtMobile = (bool) preg_match('/Mobile|Android|iPhone|iPad/i', $vtUa); $vtOs = match (true) { str_contains($vtUa, 'Windows') => 'Windows', str_contains($vtUa, 'Android') => 'Android', (bool) preg_match('/iPhone|iPad|iPod/', $vtUa) => 'iOS', str_contains($vtUa, 'Mac OS') || str_contains($vtUa, 'Macintosh') => 'macOS', str_contains($vtUa, 'Linux') => 'Linux', default => $vtUa ? 'Other' : 'Unknown', }; $vtBrowser = match (true) { $vtBot => 'Bot', str_contains($vtUa, 'Edg/') => 'Edge', str_contains($vtUa, 'OPR/') || str_contains($vtUa, 'Opera') => 'Opera', str_contains($vtUa, 'Firefox/') => 'Firefox', str_contains($vtUa, 'Chrome/') => 'Chrome', str_contains($vtUa, 'Safari/') => 'Safari', default => $vtUa ? \Illuminate\Support\Str::limit($vtUa, 16, '…') : '—', }; $vtPath = parse_url((string) $visitor->page_url, PHP_URL_PATH) ?: ($visitor->page_url ?: '/'); @endphp @empty @endforelse
Visitor & Device Page Visited Browser Visit Date Recorded Timestamp
{{ $visitor->ip_address }} {{ $vtOs }} · {{ $vtBot ? 'Crawler' : ($vtMobile ? 'Mobile' : 'Desktop') }}
{{ \Illuminate\Support\Str::limit($vtPath, 45, '…') }} @if(filter_var($visitor->page_url, FILTER_VALIDATE_URL)) @endif
{{ $vtBrowser }} {{ \Carbon\Carbon::parse($visitor->visit_date)->format('j M Y') }} @if($visitor->created_at) {{ $visitor->created_at->format('j M Y') }} {{ $visitor->created_at->format('g:i A') }} ({{ $visitor->created_at->diffForHumans() }}) @else — @endif
No visits match the criteria
Try adjusting or clearing your date range, browser or device filters.
@include('components.pagination', ['paginator' => $visitors])
{{-- Scoped Styles for Visitor Analytics Dashboard --}} @endsection