Docly

Preparing installation in GTM

Estimated reading: 3 minutes

This guide explains how to define variables and triggers, and how to set up events to track form interactions. These settings enable you to dynamically send user actions and data changes from your forms to GA4 for accurate measurement and analysis.

1. Define Variables

What are variables in GTM?

Variables in GTM allow you to extract values (e.g., donation_amount, email_opt_in) from the dataLayer or page elements. These values can then be passed as parameters in events (such as those sent to GA4).

Steps to create data layer variables in GTM:

Go to Variables tab in GTM.

Click New → Name the variable.

Choose Variable Type: Data Layer Variable

In the Data Layer Variable Name field, enter the exact key name:

  • Example: donation_amount

Then save variable.

2. Setup Event Triggers

Steps to create trigger in GTM:

  1. Go to GTM → Triggers → Click New,
    • Name your trigger clearly, like Trigger – Form Submitted (form_submitted123)
  2. Choose Trigger Type
    • Trigger Type: Custom Event
  3. Configure Custom Event Trigger
    • Event Nameform_submitted_1234 (write your event name)
    • This trigger fires on: All Custom Events (or select “Some” to add conditions)
    • If you want to limit when it fires, choose:
    • Some Custom Events
    • Condition example:
    • formId equals 123
    • OR any other Data Layer variable you’re checking
  4. Save it.

3. Create Event

Steps to create GA4 event tag in GTM:

  1. Go to GTM → Tags → Click New
  2. Name your tag clearly
  3. Set tag Type: Google Analytics: GA4 Event
    • Configuration Tag: Choose your existing GA4 Configuration Tag
    • (It has your G-XXXXXXXXXX Measurement ID)
  4. Configure Event Name
    • Event Name:
    • Example: form_submitted
    • (This is what you’ll see in GA4 later)
  5. Add Event Variables
    • Make sure you’ve already created these Data Layer Variables.
  6. You can now attach your trigger to your GA4 Event Tag.
  7. Save it

4. Publish changes

Steps to publish changes in GTM:

  1. Open Your Container in GTM
  2. Select your account and container.
  3. Check for Unsaved Changes
    • At the top, you’ll see:
    • Workspace Changes indicator.
    • This means you have unpublished tags, triggers, or variables.
  4. Click Submit (Top Right)
    • A new panel will open to publish your container.
  5. Configure Version Details
    • Version Name: (Optional but recommended)
      Example: GA4 Event Tracking for Form Submissions
    • Version Description: (Optional)
      Example: Added tag to send form_submitted_1234 event to GA4 with custom parameters.
  6. Click Publish
    • GTM will create a new container version and deploy your changes.
    • This makes your tag, trigger, and variable changes live on your site.
  7. Check Published Versions
    • Go to: Admin > Versions to view or roll back previous versions if needed.
  8. Confirm It Works:
    • Use Preview mode to test your tags before publishing.
    • Use GA4 DebugView and Realtime Reports to verify the events and parameters arrive correctly.