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:

.env
NEXT_PUBLIC_GOOGLE_ANALYTICS=G-XXXXXXXXXX

Test the integration

  1. Open the application and accept cookies in the consent banner.
  2. Open the browser's Network tab and filter for gtag.
    You should see requests to googletagmanager.com.
  3. Check your GA4 Realtime report to confirm events are being received.