Google Analytics
Learn how to set up Google Analytics tracking.
Setup
Create GA4 Property
Go to Google Analytics and create a new GA4 property for your application.
Get the Measurement ID
In your GA4 property settings, find the Measurement ID.
It follows the format G-XXXXXXXXXX.
Update the environment variables
Copy the Measurement ID and paste it beside NEXT_PUBLIC_GOOGLE_ANALYTICS in the .env file:
NEXT_PUBLIC_GOOGLE_ANALYTICS=G-XXXXXXXXXXTest the integration
- Open the application and accept cookies in the consent banner.
- Open the browser's Network tab and filter for
gtag.
You should see requests togoogletagmanager.com. - Check your GA4 Realtime report to confirm events are being received.