[Frontend] Add analytics and user behavior tracking - #216
Merged
jobbykings merged 2 commits intoJul 19, 2026
Conversation
jobbykings
approved these changes
Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #200
Summary of the issue
The platform lacked visibility into user behavior, feature adoption, and performance metrics. To better understand how users engage with the application and to identify areas for improvement, we needed an analytics solution. Crucially, this had to be privacy-respecting, GDPR compliant with a cookie consent banner, and capable of tracking Web Vitals, feature usage (like course enrollments and credential verifications), and providing an admin dashboard.
Root cause
The application had no analytics provider integrated, meaning no data was being collected for page views, routing events, Web Vitals, or custom user interactions.
Solution implemented
Integrated
next-plausible(a lightweight, privacy-focused analytics tracker) as the analytics provider. Wrapped the application with<PlausibleProvider>and enabled custom event tracking. Added aCookieConsentBannerto request user permission, tracked Web Vitals natively through Next.jsreportWebVitals, and added custom event triggers to core interactions. Additionally, created a dedicated/admin/analyticspage that embeds the Plausible shared dashboard for administrators.Key changes made
next-plausible,js-cookie, and@types/js-cookietopackage.json.src/pages/_app.tsxto include<PlausibleProvider domain="starked-education.com">and exported the Next.jsreportWebVitalsfunction to pipe performance metrics (like CLS, FID, LCP) directly to Plausible.src/components/CookieConsentBanner.tsxto handle GDPR compliance, storing the user's preference securely in a cookie.src/store/courseStore.tsto emit a custom'Course Enrollment'event when a user successfully enrolls in a course.src/components/CredentialList.tsxto emit a custom'Credential Verification'event when a user verifies a credential.src/pages/admin/analytics.tsxwith a responsive layout and an embedded Plausible analytics iframe so admins can view insights without leaving the platform.Any trade-offs or considerations
window.plausiblefunction directly; they will gracefully fail without errors if the analytics script is blocked by an adblocker.YOUR_AUTH_TOKENin the iframe source URL insideadmin/analytics.tsxwith a real shared link token from your Plausible account once it is set up.Testing steps (how to verify the fix)
npm install next-plausible js-cookieandnpm install -D @types/js-cookiein thefrontenddirectory.npm run dev.Course Enrollmentwas sent to the Plausible endpoint.Credential Verificationevent is dispatched.http://localhost:3000/admin/analyticsand verify the dashboard layout renders correctly.Please kindly review this task. If there are any corrections, improvements, adjustments, or merge conflicts that you notice regarding my implementation, I'd really appreciate your feedback. I'd also love to hear your overall review of my work on this branch. Thank you!