DEV Community

Ramandeep Singh
Ramandeep Singh

Posted on

GTM to Google Analytics GA

How to Connect GTM to Google Analytics:

Step 1: Create a Google Analytics 4 Property

  1. Go to Google Analytics

  2. Create New Property

    • Click "Start measuring" or "Create Property"
    • Enter property name: Agentic Manufacturing
    • Select your timezone and currency
    • Click "Next"
  3. Set Up Business Details

    • Choose your business size and industry
    • Select how you plan to use GA4
    • Click "Create"
  4. Get Your Measurement ID

    • Copy the Measurement ID (format: G-XXXXXXXXXX)
    • This is your GA4 property ID

Step 2: Configure GTM to Send Data to GA4

  1. Open GTM Console

  2. Create GA4 Configuration Tag

    • Go to Tags → Click "New"
    • Tag Name: GA4 - Configuration
    • Tag Type: Google Analytics: GA4 Configuration
    • Measurement ID: Enter your GA4 Measurement ID (G-XXXXXXXXXX)
    • Trigger: All Pages
    • Click "Save"
  3. Create Event Tags for Your Custom Events

    • Go to Tags → Click "New"
    • Tag Name: GA4 - Form Submission
    • Tag Type: Google Analytics: GA4 Event
    • Configuration Tag: Select your GA4 Configuration tag
    • Event Name: form_submission
    • Event Parameters: Add your custom parameters
    • Trigger: Custom Event → Event name: form_submission
    • Click "Save"
  4. Repeat for Other Events
    Create similar tags for:

    • page_view
    • form_success
    • button_click
    • navigation_click
    • scroll_depth
    • section_view

Step 3: Set Up Triggers

  1. Page View Trigger

    • Go to Triggers → Click "New"
    • Trigger Name: All Pages
    • Trigger Type: Page View
    • Click "Save"
  2. Custom Event Triggers

    • Go to Triggers → Click "New"
    • Trigger Name: Form Submission
    • Trigger Type: Custom Event
    • Event name: form_submission
    • Click "Save"
  3. Repeat for other events (form_success, button_click, etc.)

Step 4: Test and Publish

  1. Test in Preview Mode

    • Click "Preview" in GTM
    • Open your website with the preview URL
    • Interact with forms and buttons
    • Verify events are firing in the debug panel
  2. Check GA4 Real-Time

    • Go to GA4 → ReportsReports snapshot
    • Look for Real-time section
    • You should see your events appearing
  3. Publish GTM Container

    • Click "Submit" in GTM
    • Add version name: GA4 Integration
    • Click "Publish"

Step 5: Verify Connection

  1. In GA4 Console:

    • Go to ReportsEngagementEvents
    • You should see your custom events listed
  2. In Real-Time:

    • Go to ReportsReports snapshotReal-time
    • Interact with your website
    • Watch events appear in real-time

🎯 Quick Setup Template:

Here's a simplified version you can follow:

  1. Create GA4 Property → Get Measurement ID (G-XXXXXXXXXX)
  2. In GTM: Create GA4 Configuration Tag with your Measurement ID
  3. In GTM: Create Event Tags for each of your custom events
  4. Test in Preview Mode
  5. Publish GTM Container

Once connected, all your events (form submissions, button clicks, page views, etc.) will be automatically sent to GA4 where you can analyze them in reports and real-time data.

Top comments (0)