Google Analytics 4 (GA4) tracks user interactions to help monitor application health and understand user behavior. Its event-based model supports cross-platform tracking and includes enhanced privacy features. section 5.4
When adding analytics to a React application:
- Load and configure the official gtag library in index.html; accurate page-view tracking also requires handling route changes. section 5.4
- Treat react-ga and react-ga4 as libraries in maintenance mode, reflecting the shift to GA4’s measurement model. section 5.4
Initialize GA4
Add the gtag script to the document head, initialize dataLayer, and configure the GA4 measurement ID.

