Skip to Content
SEO & AnalyticsGA4 Integration

Google Analytics 4 Integration

Google Analytics 4  (GA4) is the latest version of Google Analytics. It is a free and powerful analytics tool that allows you to track your website’s traffic and behavior.

To manage GA4 and other tools, Google provides a unified platform called Google Tag Manager  (GTM). It is recommended to use Google Tag Manager to manage your website’s analytics including GA4.

Google Tag Manager Setup

To setup Google Tag Manager, you need the GTM container ID.

  1. Go to Google Tag Manager  and create a new Web Container.
  2. After creation, you’ll get two code snippets. No need to copy them. Just copy the GTM container ID like GTM-XXXXXXX.
  3. Paste the GTM container ID into the GTM_ID environment variable in your .env.local file.
GTM_ID=GTM-XXXXXXX

GA4 Setup

Get Your GA4 Measurement ID

  1. Go to Google Analytics .
  2. Navigate to Admin → Data Streams → Web.
  3. Copy your Measurement ID — it looks like G-XXXXXXXXXX.
    You’ll use this in Google Tag Manager (GTM) later.

Add Google Tag Manager to Your Site

Set up GTM in your site according to the instructions above.


Create a GA4 Configuration Tag in GTM

  1. In GTM, go to Tags → New → Tag Configuration → Google Analytics: GA4 Configuration.
  2. Paste your Measurement ID from Step 1.
  3. Enable “Send a page view event when this configuration loads”.
  4. Set the Triggering to All Pages.
  5. Click Save.

Preview, Publish & Verify

  1. In GTM, click Preview to open Tag Assistant .
  2. Visit your site and confirm the tag fires on page load.
  3. Click Submit → Publish to make it live.
  4. Go to GA4 → Reports → Realtime — you should see your visit show up within seconds.
Last updated on