Setting Up Google Analytics
Follow these steps to integrate Google Analytics.
Step 1: Create a Google Analytics Account
- Go to the Google Analytics website.
- Sign in with your Google account and create a new property for your website.
- In the left-hand menu, navigate to Admin > Data Streams.
- Click on “Create Stream” and select the Web option.
- Enter your website URL and stream name, then click “Create Stream.”
- You’ll receive a Measurement ID (e.g.,
G-XXXXXXXXXX
).
Step 2: Add Measurement ID to .env.local
- In your project’s
.env.local
file, add the following environment variable:NEXT_PUBLIC_GOOGLE_ANALYTICS=G-XXXXXXXXXX