@@ -9,8 +9,6 @@ import { trackScrollDepth } from "@/utils/analytics";
99
1010// Track scroll depth milestones using Intersection Observer
1111function setupScrollDepthTracking ( ) {
12- console . log ( "[Scroll Tracking] 🚀 Setting up scroll depth tracking..." ) ;
13-
1412 // Define depth milestones with corresponding sections
1513 const depthMarkers = [
1614 { depth : 25 , selector : "#origins" , label : "Origins" } ,
@@ -26,22 +24,13 @@ function setupScrollDepthTracking() {
2624 const observer = new IntersectionObserver (
2725 ( entries ) => {
2826 entries . forEach ( ( entry ) => {
29- console . log ( "[Scroll Observer]" , {
30- target : entry . target . id ,
31- isIntersecting : entry . isIntersecting ,
32- intersectionRatio : entry . intersectionRatio ,
33- } ) ;
34-
3527 if ( entry . isIntersecting ) {
3628 // Find which depth marker this element corresponds to
3729 const marker = depthMarkers . find ( ( m ) =>
3830 entry . target . matches ( m . selector ) ,
3931 ) ;
4032
4133 if ( marker && ! firedDepths . has ( marker . depth ) ) {
42- console . log (
43- `[Scroll Tracking] 🎯 Reached ${ marker . depth } % (${ marker . label } )` ,
44- ) ;
4534 // Track this depth milestone
4635 trackScrollDepth (
4736 "statsbomb-case-study" ,
@@ -57,31 +46,19 @@ function setupScrollDepthTracking() {
5746 } ) ;
5847 } ,
5948 {
60- // Fire when ANY part of element enters viewport
61- // Using 0.1 (10%) instead of 0.5 (50%) because sections are tall
62- // and may never have 50% visible at once
49+ // Fire when 10% of element is visible
50+ // Lower threshold needed because sections are taller than viewport
6351 threshold : 0.1 ,
6452 } ,
6553 ) ;
6654
6755 // Observe all depth marker elements
68- let observedCount = 0 ;
6956 depthMarkers . forEach ( ( marker ) => {
7057 const element = document . querySelector ( marker . selector ) ;
7158 if ( element ) {
7259 observer . observe ( element ) ;
73- observedCount ++ ;
74- console . log (
75- `[Scroll Tracking] ✅ Observing: ${ marker . selector } (${ marker . depth } %)` ,
76- ) ;
77- } else {
78- console . warn ( `[Scroll Tracking] ❌ Not found: ${ marker . selector } ` ) ;
7960 }
8061 } ) ;
81-
82- console . log (
83- `[Scroll Tracking] 📊 Total: ${ observedCount } /${ depthMarkers . length } elements observed` ,
84- ) ;
8562}
8663
8764// Run after page load (support View Transitions)
0 commit comments