- Add Rybbit server-side tracking to analytics-server.ts for order completion and revenue
- Add trackNewsletterSignup to analytics.ts and wire up NewsletterSection
- Add cart tracking to CartDrawer (cart view, remove from cart)
- All ecommerce events now track to both OpenPanel and Rybbit
- Add RybbitService for tracking e-commerce events
- Update useAnalytics hook to track with both OpenPanel and Rybbit
- Add Rybbit script to layout for page view tracking
- Track all applicable store events: product views, cart, checkout, orders, search, etc.
Complete analytics overhaul with redundant tracking:
CLIENT-SIDE (useAnalytics hook):
- Tracks user behavior in real-time
- Product views, add to cart, checkout steps
- Revenue tracking via op.revenue()
- Captures user session data
SERVER-SIDE (API route + server functions):
- POST /api/analytics/track-order endpoint
- trackOrderCompletedServer() function
- Reliable tracking that can't be blocked
- Works even if browser closes
DUAL TRACKING for order completion:
1. Client tracks immediately (session data)
2. API call to server endpoint (reliable)
3. Both sources recorded with 'source' property
Files:
- src/lib/analytics.ts - Client-side with dual tracking
- src/lib/analytics-server.ts - Server-side tracking
- src/app/api/analytics/track-order/route.ts - API endpoint
Benefits:
- ✅ 100% revenue capture (server-side backup)
- ✅ Real-time client tracking
- ✅ Ad blocker resistant
- ✅ Browser-close resistant
- ✅ Full funnel visibility
Add detailed console logs to debug why revenue tracking isn't working:
- Log when trackOrderCompleted is called
- Log revenue amount and currency
- Log success/failure of revenue tracking
This will help identify if the issue is with the op.revenue() call
or if it's failing silently.
Remove complex tracking implementation that was causing errors:
- Remove op.increment/decrement calls (causing Duplicate event errors)
- Remove complex type definitions
- Remove unused tracking methods
- Keep only essential tracking with proper error handling
This reverts to a simpler, working analytics implementation.