Skip to main content

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

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:

DimensionIDPurpose
User Roledimension1Track which user types view which content
Documentation Sectiondimension2Identify popular documentation areas
Guide Typedimension3Understand which guides are most used

Testing & Verificationโ€‹

Browser Console Methodโ€‹

  1. Open the documentation site
  2. Open browser Developer Tools (F12)
  3. Go to the Console tab
  4. 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โ€‹

  1. Go to Google Analytics
  2. Select property with ID: G-9DY20V8FQD
  3. Navigate to: Reports โ†’ Realtime
  4. View:
    • Active users
    • Current page views
    • Events in last 30 minutes

Custom Eventsโ€‹

  1. Go to: Reports โ†’ Engagement โ†’ Events
  2. Look for custom events:
    • guide_view
    • search_open
    • code_copy
    • file_download
    • Outbound clicks

Most Viewed Pagesโ€‹

  1. Go to: Reports โ†’ Engagement โ†’ Pages and screens
  2. 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โ€‹

  1. Open Developer Tools โ†’ Network tab
  2. Filter by: google-analytics.com or googletagmanager.com
  3. Check for:
    • /gtag/js?id=G-9DY20V8FQD (script load)
    • /g/collect or /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โ€‹

  1. Test in Realtime Reports: Always verify new events in GA4 Realtime before relying on them
  2. Use Debug Mode: Enable GA4 debug mode during development
  3. Respect Do Not Track: Consider implementing DNT header respect
  4. Regular Audits: Review tracked events quarterly to ensure relevance
  5. 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