-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add analytics tracking #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements comprehensive GA4 custom event tracking across the site to measure user engagement and conversions. The implementation follows a well-structured approach with type-safe analytics utilities and consistent tracking patterns across components.
Changes:
- Adds a new analytics utility module (
src/lib/analytics.ts) with type-safe event tracking functions and utilities - Implements impression and action tracking (view/click events) for buy buttons, free chapter forms, and blog CTAs to enable CTR and conversion rate calculations
- Adds engagement tracking including scroll depth, blog read completion, outbound links, chapter expansions, and internal navigation
- Includes A/B testing support for 10 blog promo variants (promo01-promo10) to identify best-performing CTAs
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib/analytics.ts |
New analytics utility module with type-safe event tracking functions, TypeScript interfaces, and helper utilities for GA4 integration |
src/components/pages/Home/components/BuyButtons.astro |
Adds view and click tracking for buy buttons with format (print/ebook) and location tracking |
src/components/pages/Home/FreeChapter.astro |
Implements form view and submission tracking for conversion rate analysis |
src/components/blog/BookPromo.astro |
Adds CTA tracking with variant support (promo01-promo10) for A/B testing; changes double quotes to single quotes in alt text |
src/components/blog/BlogLayout.astro |
Implements scroll depth tracking (25%, 50%, 75%, 100%) and blog read completion events |
src/components/pages/Home/Chapters.astro |
Tracks chapter expansion events to measure content engagement |
src/components/pages/Home/Hero.astro |
Updates BuyButtons component to pass location="hero" |
src/components/pages/Home/Reviews.astro |
Updates BuyButtons component to pass location="reviews" |
src/components/pages/Home/Quotes.astro |
Updates BuyButtons component to pass location="quotes" |
src/components/pages/Home/ProblemStatement.astro |
Updates BuyButtons component to pass location="problem_statement" |
src/components/pages/Home/ActionPlan.astro |
Updates BuyButtons component to pass location="action_plan" |
src/Layout.astro |
Adds global outbound link and internal navigation tracking via event delegation |
.claude/settings.local.json |
Adds permissions for analytics-related MCP tools and bash commands |
.claude/features/analytics-events-tracking/tasks.md |
Comprehensive documentation of implementation tasks, event schemas, and success metrics |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4ad4373 to
c8b5c42
Compare
|
@copilot check if all the open comments have been resolved to your liking! |
|
@copilot I have already done the fixes, just review if all looks good now! 😞 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 14 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* feat: add analytics tracking * chore: typing improvements * chore: fixes after review * fix: small glitch in book promo (image not clickable) * chore: various fixes and improvements after review * chore: small linting fix
Summary
This PR implements comprehensive GA4 custom event tracking across the site to measure user engagement and conversions. The implementation enables calculating click-through rates (CTR) and conversion rates by tracking both impressions (view events) and actions (click/submit events).
Key Features
Files Changed
src/lib/analytics.tssrc/components/pages/Home/components/BuyButtons.astrosrc/components/pages/Home/FreeChapter.astrosrc/components/blog/BookPromo.astrosrc/components/blog/BlogLayout.astrosrc/components/pages/Home/Chapters.astrosrc/Layout.astroTest Plan
GA4 Custom Dimensions & Metrics Setup (manual step)
Based on the analytics implementation, here's the detailed table of GA4 custom dimensions and metrics you need to create:
Custom Dimensions (Event-scoped)
book_formatbutton_locationcta_variantcta_positioncta_typecontent_typeform_locationnavigation_typelink_domainlink_textlink_urlsource_pagefrom_pageto_pagechapter_titleCustom Metrics (Event-scoped)
percent_scrolledestimated_read_timetime_on_pagechapter_numberHow to Create in GA4