This document outlines the analytics tracking implementation for the SQL Learning Platform using Vercel Analytics and Speed Insights.
The application now includes comprehensive analytics tracking to understand user behavior, learning patterns, and platform performance.
@vercel/analytics- Page views and custom event tracking@vercel/speed-insights- Core Web Vitals and performance monitoring
Located in src/App.jsx:
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/react';
// Added to the main App component
<Analytics />
<SpeedInsights />File: src/services/analytics.js
Provides utility functions for tracking specific user interactions:
trackModuleStart()- When user begins a practice moduletrackQuestionCompleted()- Question submission with correctness and scoretrackChatbotMessage()- Chatbot interactions with contexttrackDynamicExample()- AI-generated example requeststrackCodeCopy()- Code copying eventstrackAnalyticsView()- Analytics page visitstrackChatbotFullScreen()- Full-screen chatbot usagetrackProgressMilestone()- Learning achievementstrackDifficultyChange()- Difficulty level adjustmentstrackCheatSheetSearch()- Search functionality usage
-
Module Started:
module_startedmodule_id: Module identifiermodule_name: Human-readable module name
-
Question Completed:
question_completedmodule_id: Current modulequestion_id: Unique question identifieris_correct: Boolean resultscore: Numerical score (0-1)difficulty: Question difficulty level
-
Code Copied:
code_copiedcode_type: Type of code (sql, example, solution)location: Where it was copied from (practice, cheatsheet, chatbot)
-
Chatbot Interaction:
chatbot_interactioncontext_page: Current page user is oncontext_module: Current learning modulemessage_type: Type of interaction
-
Full-Screen Toggle:
chatbot_fullscreen_toggleis_fullscreen: Boolean state
-
Dynamic Example Generated:
dynamic_example_generatedsql_command: SQL command for examplecategory: Command category
-
Search Usage:
cheatsheet_searchsearch_term: What user searched forresults_count: Number of results found
- Analytics Page View:
analytics_vieweduser_id: User identifier
-
Progress Milestone:
progress_milestonemilestone: Achievement typemodule_id: Related moduletotal_progress: Overall completion percentage
-
Difficulty Change:
difficulty_changedmodule_id: Module where change occurredfrom_difficulty: Previous levelto_difficulty: New level
Analytics will automatically work when deployed to Vercel. No additional configuration needed.
You may need to set up environment variables or configure the analytics provider differently depending on your hosting platform.
With these events, you can analyze:
-
Learning Patterns
- Which modules are most challenging
- Time spent on different difficulty levels
- Common mistake patterns
-
Feature Usage
- Chatbot engagement rates
- Cheat sheet search patterns
- Code copying behavior
-
User Journey
- Module completion rates
- Drop-off points
- Help-seeking behavior
-
Performance Metrics
- Page load times
- Core Web Vitals
- User engagement duration
- Vercel Dashboard: Visit your Vercel project dashboard
- Analytics Tab: Click on the Analytics tab
- Custom Events: View custom events in the Events section
- Speed Insights: Monitor performance metrics
To add new tracking events:
- Add a new function to
src/services/analytics.js - Import and call the function in the relevant component
- Follow the existing pattern for event naming and properties
Example:
// In analytics.js
trackNewFeature: (featureName, userAction) => {
track('feature_used', {
feature_name: featureName,
user_action: userAction
});
}
// In component
import { analytics } from '../services/analytics';
analytics.trackNewFeature('advanced_search', 'filter_applied');All analytics data is processed according to Vercel's privacy policy. No personally identifiable information is tracked beyond user session data for learning progress.
Analytics tracking is now active across the entire SQL Learning Platform! 📊