2026-03-18 12:18:07 +02:00
|
|
|
<x-app-layout>
|
|
|
|
|
<x-slot name="header">
|
|
|
|
|
<div class="flex items-center justify-between flex-wrap gap-4">
|
|
|
|
|
<div class="flex items-center gap-3">
|
|
|
|
|
<a href="{{ route('websites.index') }}" class="text-gray-400 hover:text-gray-600">
|
|
|
|
|
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
|
|
|
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5 8.25 12l7.5-7.5" />
|
|
|
|
|
</svg>
|
|
|
|
|
</a>
|
|
|
|
|
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
|
|
|
|
{{ $website->name }}
|
|
|
|
|
</h2>
|
|
|
|
|
<span class="text-sm text-gray-400">{{ $website->domain }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
{{-- Real-time indicator --}}
|
|
|
|
|
<div
|
|
|
|
|
x-data="realtimeWidget('{{ route('dashboard.realtime', $website) }}')"
|
|
|
|
|
x-init="start()"
|
|
|
|
|
class="flex items-center gap-2 rounded-md bg-green-50 px-3 py-1.5 text-sm"
|
|
|
|
|
>
|
|
|
|
|
<span class="relative flex h-2.5 w-2.5">
|
|
|
|
|
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"></span>
|
|
|
|
|
<span class="relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"></span>
|
|
|
|
|
</span>
|
|
|
|
|
<span class="font-medium text-green-800">
|
|
|
|
|
<span x-text="count"></span> active now
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<x-date-range-picker :website="$website" :from="$from" :to="$to" />
|
|
|
|
|
|
|
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<a href="{{ route('websites.snippet', $website) }}" class="text-sm text-gray-500 hover:text-gray-700">Snippet</a>
|
|
|
|
|
<a href="{{ route('websites.edit', $website) }}" class="text-sm text-gray-500 hover:text-gray-700">Settings</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</x-slot>
|
|
|
|
|
|
|
|
|
|
<div class="py-8">
|
|
|
|
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
|
|
|
|
|
|
|
|
|
|
{{-- Metric Cards --}}
|
|
|
|
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6">
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Page Views</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ number_format($metrics['page_views']) }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Unique Visitors</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ number_format($metrics['visitors']) }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Sessions</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ number_format($metrics['sessions']) }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Bounce Rate</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ $metrics['bounce_rate'] }}%</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Avg. Duration</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ gmdate('i:s', (int) $metrics['avg_duration']) }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-5">
|
|
|
|
|
<dt class="text-sm font-medium text-gray-500 truncate">Pages / Session</dt>
|
|
|
|
|
<dd class="mt-1 text-2xl font-bold text-gray-900">{{ $metrics['avg_pages'] }}</dd>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{-- Visitors Chart --}}
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
|
|
|
|
|
<div class="flex items-center justify-between mb-4">
|
|
|
|
|
<h3 class="text-base font-semibold text-gray-900">Visitors & Page Views</h3>
|
|
|
|
|
<div class="flex items-center gap-4 text-xs text-gray-500">
|
|
|
|
|
<span class="flex items-center gap-1.5">
|
|
|
|
|
<span class="inline-block w-3 h-0.5 rounded bg-indigo-500"></span> Visitors
|
|
|
|
|
</span>
|
|
|
|
|
<span class="flex items-center gap-1.5">
|
|
|
|
|
<span class="inline-block w-3 h-0.5 rounded bg-emerald-500"></span> Page Views
|
|
|
|
|
</span>
|
|
|
|
|
<span class="flex items-center gap-1.5">
|
|
|
|
|
<span class="inline-block w-3 h-0.5 rounded bg-amber-400"></span> Sessions
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style="height: 320px;">
|
|
|
|
|
<canvas id="visitors-chart"></canvas>
|
|
|
|
|
</div>
|
2026-03-18 13:32:36 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-18 16:59:39 +02:00
|
|
|
{{-- Goal Completions --}}
|
|
|
|
|
@if ($goalConversions->isNotEmpty())
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
|
|
|
|
|
<div class="flex items-center justify-between mb-4">
|
|
|
|
|
<h3 class="text-base font-semibold text-gray-900">Goal Completions</h3>
|
|
|
|
|
<div class="flex items-center gap-3">
|
|
|
|
|
<a href="{{ route('reports.conversions', [$website] + request()->only(['range', 'from', 'to'])) }}" class="text-sm text-indigo-600 hover:text-indigo-800">View report</a>
|
|
|
|
|
<a href="{{ route('goals.index', $website) }}" class="text-sm text-gray-500 hover:text-gray-700">Manage goals</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
|
|
|
@foreach ($goalConversions->where('is_active', true)->take(6) as $goal)
|
|
|
|
|
<div class="rounded-lg border border-gray-200 p-4">
|
|
|
|
|
<div class="flex items-center justify-between mb-1">
|
|
|
|
|
<span class="text-sm font-medium text-gray-900 truncate">{{ $goal->name }}</span>
|
|
|
|
|
<span class="text-xs text-gray-500">{{ $goal->conversion_rate }}%</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="text-2xl font-bold text-gray-900">{{ number_format($goal->completions) }}</div>
|
|
|
|
|
@if ($goal->total_value)
|
|
|
|
|
<div class="text-xs text-gray-500 mt-0.5">${{ number_format($goal->total_value, 2) }} value</div>
|
|
|
|
|
@endif
|
|
|
|
|
<div class="mt-2 w-full bg-gray-100 rounded-full h-1.5">
|
|
|
|
|
<div class="bg-emerald-500 h-1.5 rounded-full" style="width: {{ min($goal->conversion_rate, 100) }}%"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@endforeach
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{{-- Sparkline chart --}}
|
|
|
|
|
@if ($goalChartData->sum('completions') > 0)
|
|
|
|
|
<div class="mt-4" style="height: 120px;">
|
|
|
|
|
<canvas id="goal-sparkline"></canvas>
|
|
|
|
|
</div>
|
|
|
|
|
@endif
|
|
|
|
|
</div>
|
|
|
|
|
@endif
|
|
|
|
|
|
2026-03-18 13:32:36 +02:00
|
|
|
{{-- Quick Report Links --}}
|
|
|
|
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg p-6">
|
|
|
|
|
<h3 class="text-base font-semibold text-gray-900 mb-4">Reports</h3>
|
|
|
|
|
@php $q = request()->only(['range', 'from', 'to']); @endphp
|
|
|
|
|
<div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
|
|
|
|
<div>
|
|
|
|
|
<h4 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Audience</h4>
|
|
|
|
|
<div class="space-y-1">
|
|
|
|
|
<a href="{{ route('reports.geographic', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Geographic</a>
|
|
|
|
|
<a href="{{ route('reports.technology', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Technology</a>
|
|
|
|
|
<a href="{{ route('reports.language', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Language</a>
|
|
|
|
|
<a href="{{ route('reports.new-vs-returning', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">New vs Returning</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h4 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Acquisition</h4>
|
|
|
|
|
<div class="space-y-1">
|
|
|
|
|
<a href="{{ route('reports.sources', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Traffic Sources</a>
|
|
|
|
|
<a href="{{ route('reports.campaigns', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Campaigns</a>
|
|
|
|
|
<a href="{{ route('reports.referrers', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Referrers</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h4 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Behavior</h4>
|
|
|
|
|
<div class="space-y-1">
|
|
|
|
|
<a href="{{ route('reports.pages', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Pages</a>
|
|
|
|
|
<a href="{{ route('reports.landing-pages', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Landing Pages</a>
|
|
|
|
|
<a href="{{ route('reports.exit-pages', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Exit Pages</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-03-18 16:59:39 +02:00
|
|
|
<h4 class="text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2">Events & Conversions</h4>
|
2026-03-18 13:32:36 +02:00
|
|
|
<div class="space-y-1">
|
|
|
|
|
<a href="{{ route('reports.events', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Events Overview</a>
|
2026-03-18 16:59:39 +02:00
|
|
|
<a href="{{ route('reports.conversions', [$website] + $q) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Conversions</a>
|
|
|
|
|
<a href="{{ route('goals.index', $website) }}" class="block text-sm text-indigo-600 hover:text-indigo-800">Manage Goals</a>
|
2026-03-18 13:32:36 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-18 12:18:07 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@push('scripts')
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
const raw = @json($chartData);
|
|
|
|
|
const labels = raw.map(d => d.period);
|
|
|
|
|
const visitors = raw.map(d => d.visitors);
|
|
|
|
|
const pageViews = raw.map(d => d.page_views);
|
|
|
|
|
const sessions = raw.map(d => d.sessions);
|
|
|
|
|
|
|
|
|
|
new Chart(document.getElementById('visitors-chart'), {
|
|
|
|
|
type: 'line',
|
|
|
|
|
data: {
|
|
|
|
|
labels: labels,
|
|
|
|
|
datasets: [
|
|
|
|
|
{
|
|
|
|
|
label: 'Visitors',
|
|
|
|
|
data: visitors,
|
|
|
|
|
borderColor: 'rgb(99, 102, 241)',
|
|
|
|
|
backgroundColor: 'rgba(99, 102, 241, 0.08)',
|
|
|
|
|
fill: true,
|
|
|
|
|
tension: 0.3,
|
|
|
|
|
pointRadius: labels.length > 60 ? 0 : 3,
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Page Views',
|
|
|
|
|
data: pageViews,
|
|
|
|
|
borderColor: 'rgb(16, 185, 129)',
|
|
|
|
|
backgroundColor: 'rgba(16, 185, 129, 0.05)',
|
|
|
|
|
fill: true,
|
|
|
|
|
tension: 0.3,
|
|
|
|
|
pointRadius: labels.length > 60 ? 0 : 3,
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: 'Sessions',
|
|
|
|
|
data: sessions,
|
|
|
|
|
borderColor: 'rgb(251, 191, 36)',
|
|
|
|
|
backgroundColor: 'rgba(251, 191, 36, 0.05)',
|
|
|
|
|
fill: true,
|
|
|
|
|
tension: 0.3,
|
|
|
|
|
pointRadius: labels.length > 60 ? 0 : 3,
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
responsive: true,
|
|
|
|
|
maintainAspectRatio: false,
|
|
|
|
|
interaction: { intersect: false, mode: 'index' },
|
|
|
|
|
plugins: {
|
|
|
|
|
legend: { display: false },
|
|
|
|
|
tooltip: {
|
|
|
|
|
backgroundColor: 'rgba(17, 24, 39, 0.9)',
|
|
|
|
|
padding: 12,
|
|
|
|
|
cornerRadius: 8,
|
|
|
|
|
titleFont: { size: 13 },
|
|
|
|
|
bodyFont: { size: 12 },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
scales: {
|
|
|
|
|
x: {
|
|
|
|
|
grid: { display: false },
|
|
|
|
|
ticks: {
|
|
|
|
|
maxTicksLimit: 12,
|
|
|
|
|
font: { size: 11 },
|
|
|
|
|
color: '#9ca3af',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
y: {
|
|
|
|
|
beginAtZero: true,
|
|
|
|
|
grid: { color: 'rgba(0,0,0,0.04)' },
|
|
|
|
|
ticks: {
|
|
|
|
|
font: { size: 11 },
|
|
|
|
|
color: '#9ca3af',
|
|
|
|
|
precision: 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-18 16:59:39 +02:00
|
|
|
// Goal sparkline
|
|
|
|
|
const goalCanvas = document.getElementById('goal-sparkline');
|
|
|
|
|
if (goalCanvas) {
|
|
|
|
|
const goalRaw = @json($goalChartData);
|
|
|
|
|
new Chart(goalCanvas, {
|
|
|
|
|
type: 'line',
|
|
|
|
|
data: {
|
|
|
|
|
labels: goalRaw.map(d => d.period),
|
|
|
|
|
datasets: [{
|
|
|
|
|
data: goalRaw.map(d => d.completions),
|
|
|
|
|
borderColor: 'rgb(16, 185, 129)',
|
|
|
|
|
backgroundColor: 'rgba(16, 185, 129, 0.1)',
|
|
|
|
|
fill: true,
|
|
|
|
|
tension: 0.3,
|
|
|
|
|
pointRadius: 0,
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
}],
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
responsive: true,
|
|
|
|
|
maintainAspectRatio: false,
|
|
|
|
|
plugins: { legend: { display: false }, tooltip: { enabled: false } },
|
|
|
|
|
scales: {
|
|
|
|
|
x: { display: false },
|
|
|
|
|
y: { display: false, beginAtZero: true },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 12:18:07 +02:00
|
|
|
function realtimeWidget(url) {
|
|
|
|
|
return {
|
|
|
|
|
count: {{ $activeVisitors }},
|
|
|
|
|
start() {
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
fetch(url)
|
|
|
|
|
.then(r => r.json())
|
|
|
|
|
.then(d => { this.count = d.active; })
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
}, 30000);
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
@endpush
|
|
|
|
|
</x-app-layout>
|