feat: add automatic 404 detection, scroll depth tracking, and scroll depth dashboard card

- 404 detection: checks document.title for "404" or "not found", fires custom event, SPA-aware
- Scroll depth: passive scroll listener fires events at 25/50/75/100% thresholds
- ScrollDepth dashboard card: progress bar visualization showing % of visitors reaching each threshold
- Scroll events filtered out of GoalStats to avoid duplication
- Both features on by default, opt-out via data-no-404 / data-no-scroll
This commit is contained in:
Usman Baig
2026-03-06 20:00:22 +01:00
parent 53a0341925
commit 8b1d196812
4 changed files with 151 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ import TechSpecs from '@/components/dashboard/TechSpecs'
import Chart from '@/components/dashboard/Chart'
import PerformanceStats from '@/components/dashboard/PerformanceStats'
import GoalStats from '@/components/dashboard/GoalStats'
import ScrollDepth from '@/components/dashboard/ScrollDepth'
import Campaigns from '@/components/dashboard/Campaigns'
import {
useDashboardOverview,
@@ -380,8 +381,9 @@ export default function SiteDashboardPage() {
<Campaigns siteId={siteId} dateRange={dateRange} />
</div>
<div className="mb-8">
<GoalStats goalCounts={goalsData?.goal_counts ?? []} />
<div className="grid gap-6 lg:grid-cols-2 mb-8">
<GoalStats goalCounts={(goalsData?.goal_counts ?? []).filter(g => !/^scroll_\d+$/.test(g.event_name))} />
<ScrollDepth goalCounts={goalsData?.goal_counts ?? []} totalPageviews={stats.pageviews} />
</div>
<DatePicker