๐ŸŽฏ GTM Setup Guide

Step-by-Step Guide to Setting Up Google Tag Manager

Current Status

  • โœ… GTM Container: GTM-WKCPQZ3G
  • โœ… HTML file created with GTM code
  • โณ Need to: Create GA4 Configuration Tag
  • โณ Need to: Publish container

๐Ÿ“ Step-by-Step: Create Your First Tag

Step 1: Get Your GA4 Measurement ID

  1. Go to Google Analytics
  2. Click Admin (gear icon, bottom left)
  3. Under Property, click Data Streams
  4. Click on your web stream
  5. Copy your Measurement ID (format: G-XXXXXXXXXX)

Don't have GA4 yet?

  • Go to Admin โ†’ Create Property โ†’ Web โ†’ Enter site details
  • Copy the Measurement ID that's generated

Step 2: Create GA4 Configuration Tag in GTM

  1. In GTM, click "Add a new tag" (or go to Tags โ†’ New)
  2. Tag Configuration:
    • Click "Tag Configuration"
    • Select "Google Analytics: GA4 Configuration"
  3. Enter Measurement ID:
    • Paste your GA4 Measurement ID (e.g., G-ABC123XYZ)
    • Leave other fields as default
  4. Set Trigger:
    • Click "Triggering" section
    • Click the pencil icon
    • Select "All Pages" (this fires on every page load)
    • Click "Save"
  5. Name Your Tag:
    • At the top, name it: GA4 - Configuration
    • Click "Save"

Step 3: Create Click Event Tag

  1. Create New Tag:
    • Click Tags โ†’ New
  2. Tag Configuration:
    • Click "Tag Configuration"
    • Select "Google Analytics: GA4 Event"
  3. Configure Event:
    • Configuration Tag: Select your GA4 - Configuration tag
    • Event Name: button_click
    • Leave other fields as default
  4. Set Trigger:
    • Click "Triggering" section
    • Click the pencil icon โ†’ "New"
    • Trigger Type: "Click - All Elements"
    • Trigger Name: Click - Test Button
    • Under "This trigger fires on": Select "Some Clicks"
    • Condition:
      • Variable: Click Element
      • Condition: matches CSS selector
      • Value: #testButton
    • Click "Save"
  5. Name Your Tag:
    • Name: GA4 - Button Click Event
    • Click "Save"

Step 4: Preview & Test

  1. Enter Preview Mode:
    • Click "Preview" button (top right)
    • Enter your localhost URL: http://localhost/gtm-learning/index.php
    • Click "Connect"
  2. Test Your Setup:
    • A new browser tab will open
    • You'll see GTM Preview panel at the bottom
    • Click the "Click Me" button on your page
    • In Preview panel, you should see:
      • โœ… gtm.js loaded
      • โœ… GA4 - Configuration tag fired
      • โœ… GA4 - Button Click Event tag fired (when you click)
  3. Verify Events:
    • In Preview panel, click on each tag
    • Check that events are firing correctly
    • Look for any errors (red indicators)

Step 5: Publish Your Container

  1. Submit Changes:
    • Click "Submit" button (top right, blue)
    • Version Name: Initial GA4 Setup
    • Version Description: Added GA4 Configuration and Button Click Event
    • Click "Publish"
  2. Verify:
    • The "Workspace Changes: 0" should reset
    • Your tags are now live!

Step 6: Verify in GA4

  1. Open GA4 DebugView:
    • Go to Google Analytics
    • Navigate to Reports โ†’ DebugView
    • (Or Admin โ†’ DebugView)
  2. Enable Debug Mode:
    • Install Tag Assistant Legacy Chrome extension
    • OR add ?debug_mode=true to your URL
    • OR use Chrome DevTools โ†’ Application โ†’ Cookies โ†’ Add debug_mode=true
  3. Test Again:
    • Open your learning platform page
    • Click the buttons
    • You should see events in real-time in DebugView:
      • page_view
      • button_click
      • custom_event

โœ… Verification Checklist

  • GA4 Configuration tag created
  • Button Click Event tag created
  • Both tags have correct triggers
  • Preview mode shows tags firing
  • Container published successfully
  • Events appear in GA4 DebugView
  • Events appear in GA4 Realtime reports

๐Ÿ› Troubleshooting

"No Recent Data" Warning Still Shows

Solution: This is normal for new containers. It will disappear after:

  1. You publish your container
  2. Your page loads with GTM code
  3. Tags fire successfully
  4. Wait 24-48 hours for the warning to clear

Tags Not Firing in Preview

  • Check that your localhost URL is correct
  • Verify GTM code is in your HTML (check Network tab)
  • Make sure triggers are configured correctly
  • Check browser console for errors

Events Not Appearing in GA4

  • Verify Measurement ID is correct
  • Check that container is published
  • Enable DebugView to see real-time events
  • Wait a few minutes for data to process

Preview Mode Not Connecting

  • Make sure you're using the exact URL (including http:// or https://)
  • Try refreshing the preview connection
  • Check if ad blockers are interfering

๐Ÿ“Š What You Should See

In GTM Preview:

โœ… gtm.js - Loaded
โœ… GA4 - Configuration - Fired
โœ… GA4 - Button Click Event - Fired (when button clicked)

In GA4 DebugView:

Event: page_view
Event: button_click
Event: custom_event

In GA4 Realtime:

  • Your active session
  • Events firing in real-time
  • User location and device info

๐ŸŽฏ Next Steps

Once basic tracking works:

  1. Add More Events:
    • Scroll tracking
    • Form submissions
    • Video plays
    • Outbound link clicks
  2. Set Up Conversions:
    • Mark important events as conversions in GA4
    • Track goals and objectives
  3. Create Custom Dimensions:
    • Track user segments
    • Add custom data to events
  4. Set Up Google Ads:
    • Link GA4 to Google Ads
    • Track ad conversions
    • Import conversions to Ads