-
Notifications
You must be signed in to change notification settings - Fork 108
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
Migrate to GTM-based Analytics Implementation #5413
base: GTM-migration
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
Overview
This PR introduces a new analytics implementation using Google Tag Manager (GTM) that separates click tracking from programmatic events, providing better maintainability and reducing code complexity.
Key Changes
Implemented a new
CowAnalyticsGtm
class that handles both:Introduced type-safe event definitions and transformations for GA4 compatibility
Removed redundant console logging for cleaner production code
Implemented proper singleton pattern for analytics instance management
Removed global click listener in favor of GTM's native event handling:
Changed event flow architecture:
Unrelated: fixed hydration errors on some cow-fi pages
GTM Setup Required
To make this work, the following GTM configuration is required:
Create a new GTM Trigger:
Create GTM Variable for click events:
Create GA4 Event Tag:
Usage Examples
Click Events
Programmatic Events
Testing
Notes