Analytics & Tracking
This documentation site uses Google Analytics 4 (GA4) to understand how users interact with our documentation and improve the user experience.
Overviewโ
Tracking ID: G-9DY20V8FQD
Our GA4 implementation includes:
- Standard page view tracking
- Enhanced measurement features
- Custom event tracking for documentation-specific interactions
- Privacy-focused configuration with IP anonymization
What We Trackโ
1. Page Views ๐โ
Automatically tracked for all pages to understand which documentation is most valuable.
2. Guide Section Views ๐โ
When users view role-specific guides (teachers, parents, students, etc.), we track:
- Guide type (e.g., "teacher-guide", "parent-guide")
- Page path
- Time spent on page
Event Name: guide_view
3. Search Interactions ๐โ
Tracks when users open the documentation search:
- Search button clicks
- Search box interactions
Event Name: search_open
4. External Link Clicks ๐โ
Monitors clicks on external links to understand what external resources users need:
- Destination URL
- Link context
Event Name: click (category: outbound)
5. Code Snippet Copies ๐โ
Tracks when users copy code examples:
- Code snippet copied
- Page where code was copied from
Event Name: code_copy
6. File Downloads โฌ๏ธโ
Monitors documentation and resource downloads:
- File name
- File URL
- Download timestamp
Event Name: file_download
Privacy & Complianceโ
Our analytics implementation respects user privacy:
โ
IP Anonymization: All IP addresses are anonymized
โ
Secure Cookies: SameSite=None;Secure flags set
โ
No PII: We don't collect personally identifiable information
โ
GDPR Compliant: Follows European data protection regulations
Custom Dimensionsโ
We use custom dimensions to better understand documentation usage:
| Dimension | ID | Purpose |
|---|---|---|
| User Role | dimension1 | Track which user types view which content |
| Documentation Section | dimension2 | Identify popular documentation areas |
| Guide Type | dimension3 | Understand which guides are most used |
Testing & Verificationโ
Browser Console Methodโ
- Open the documentation site
- Open browser Developer Tools (F12)
- Go to the Console tab
- Run:
verifyGA4()
This will check:
- โ Google Tag Manager script loaded
- โ dataLayer exists
- โ gtag function available
- โ Tracking ID configured
- โ Custom events setup
Send Test Eventโ
// In browser console
testGA4Events()
This sends a test event to GA4. Verify in:
- GA4 Dashboard โ Reports โ Realtime โ Events
Monitor Eventsโ
// Monitor for 10 seconds
monitorGA4(10000)
This will log all GA4 events to the console as they occur.
Automated Testingโ
We provide a Node.js script for automated verification using Puppeteer:
Installationโ
npm install puppeteer --save-dev
Run Verificationโ
node scripts/verify-ga4.js
Or programmatically:
const { verifyGA4WithPuppeteer } = require('./scripts/verify-ga4.js');
// Test local development
await verifyGA4WithPuppeteer('http://localhost:3000');
// Test production
await verifyGA4WithPuppeteer('https://docs.4sch.com');
Viewing Analytics Dataโ
Real-Time Reportsโ
- Go to Google Analytics
- Select property with ID:
G-9DY20V8FQD - Navigate to: Reports โ Realtime
- View:
- Active users
- Current page views
- Events in last 30 minutes
Custom Eventsโ
- Go to: Reports โ Engagement โ Events
- Look for custom events:
guide_viewsearch_opencode_copyfile_download- Outbound clicks
Most Viewed Pagesโ
- Go to: Reports โ Engagement โ Pages and screens
- Sort by:
- Views
- Average engagement time
- Event count
Configuration Detailsโ
The GA4 implementation is configured in docusaurus.config.js:
gtag('config', 'G-9DY20V8FQD', {
'send_page_view': true,
'anonymize_ip': true,
'cookie_flags': 'SameSite=None;Secure',
'custom_map': {
'dimension1': 'user_role',
'dimension2': 'documentation_section',
'dimension3': 'guide_type'
}
});
Debuggingโ
Check if GA4 is Loadedโ
// Browser console
console.log('dataLayer:', window.dataLayer);
console.log('gtag function:', typeof window.gtag);
View Network Requestsโ
- Open Developer Tools โ Network tab
- Filter by:
google-analytics.comorgoogletagmanager.com - Check for:
/gtag/js?id=G-9DY20V8FQD(script load)/g/collector/j/collect(event tracking)
Common Issuesโ
Issue: Events not appearing in GA4
Solution:
- Check browser console for errors
- Verify gtag script loaded successfully
- Wait 24-48 hours for data to appear in non-realtime reports
- Check Realtime reports for immediate verification
Issue: Duplicate events
Solution:
- Ensure GA4 is only initialized once
- Check for multiple gtag script tags
- Verify no browser extensions are interfering
Best Practicesโ
- Test in Realtime Reports: Always verify new events in GA4 Realtime before relying on them
- Use Debug Mode: Enable GA4 debug mode during development
- Respect Do Not Track: Consider implementing DNT header respect
- Regular Audits: Review tracked events quarterly to ensure relevance
- Document Changes: Update this page when modifying tracking implementation
Resourcesโ
Supportโ
If you have questions about analytics tracking or need help interpreting data:
- Contact: Technical Team
- Documentation: This page
- Verification Script:
scripts/verify-ga4.js