This project has been migrated from direct Google Analytics 4 implementation to Google Tag Manager (GTM) for better tracking flexibility and easier management of marketing tools.
- Go to Google Tag Manager
- Create a new account/container for your website
- Note your GTM Container ID (format: GTM-XXXXXXX)
- Go to your GitHub repository
- Navigate to Settings → Secrets and variables → Actions
- Click New repository secret
- Name:
PUBLIC_GTM_ID - Value:
GTM-XXXXXXX(your actual GTM container ID)
The GitHub Actions workflow has been updated to use this secret during build.
PUBLIC_GTM_ID=GTM-XXXXXXX
If you prefer simplicity, replace GTM-XXXXXXX directly in the GTM components with your actual GTM ID.
- In your GTM container, create a new Google Analytics: GA4 Configuration tag
- Use your existing Measurement ID:
G-Z2X2PB0P4E - Set the trigger to All Pages
- Publish the container
With GTM, you can now easily add:
- Facebook Pixel
- LinkedIn Insight Tag
- Conversion tracking
- Custom events
- And more...
src/components/analytics/GTM.astro- GTM head scriptsrc/components/analytics/GTMBody.astro- GTM body script (noscript fallback)src/layouts/BaseLayout.astro- Updated to use GTM instead of direct GA4
After confirming GTM works correctly:
src/components/analytics/Google.astrosrc/components/analytics/google.js
- Install GTM container ID
- Use Google Tag Assistant to verify GTM is firing
- Check GA4 real-time reports to confirm data is flowing
- Centralized Management: All tracking codes in one place
- No Code Deployments: Add new tracking without code changes
- Advanced Tracking: Easy setup of conversion tracking, custom events
- Team Collaboration: Marketing team can manage tags independently
- Version Control: GTM has built-in version control and rollback
- Testing: Preview and debug mode before publishing changes