Google Tag Manager Event Tracking Tutorial: Track Button Clicks, Forms and Custom Events

Digital Team 27 Nov 2026 Tutorial

Analyse or Listen to This Article

Open this article in your preferred AI assistant, or listen with the built-in voice player.

ANALYSE WITH AI
LISTEN TO ARTICLE

Ready to listen.

Introduction

If you want to measure real user actions on your website - button clicks, form submissions, WhatsApp taps, phone calls, or custom interactions - you need event tracking. This Google Tag Manager event tracking tutorial shows how to plan and implement events in a way that is reliable, testable, and useful for marketing decisions. The goal is not to track everything. The goal is to track the right actions accurately.

What Is Google Tag Manager Event Tracking?

Google Tag Manager (GTM) is a tag management system that lets you deploy and manage tracking tags without editing website code for every change. Event tracking in GTM means capturing user interactions and sending them to analytics or advertising platforms. For most websites, GA4 is the main destination.

GTM works well when you have a clear measurement plan. Without a plan, teams create random tags, duplicate events, and reports become unreliable.

How GTM Works: Tags, Triggers, and Variables

Component What It Does Example
Tag Sends data or loads a tool GA4 Event tag for generate_lead
Trigger Defines when a tag fires Click URL contains wa.me
Variable Provides dynamic value Click Text, Page Path, DLV - form_name

A tag without a trigger never fires. A trigger without the right variable conditions may fire on the wrong element. Variables make the data useful by adding context.

Prerequisites and Setup

  • GTM account and container access (Edit/Publish).
  • Website access (CMS, theme, or developer).
  • GA4 property and Measurement ID.
  • A list of business actions to track, which a digital marketing checklist can help you draft.
  • A testing process using Preview and DebugView.

Step 1: Install GTM Correctly

Create a Web container in GTM and install the two snippets. The script goes as high as possible in the <head>; the noscript iframe goes immediately after the opening <body> tag.

On Laravel, you can place this in your main layout Blade file (for example resources/views/layouts/app.blade.php) so it loads on all pages. In other CMS platforms, use the theme header/body settings or a trusted plugin. After installation, verify in GTM Preview. A well-structured business website with a shared layout makes this much easier.

Step 2: Configure GA4 Base Tag

In GTM, create a Google tag (or GA4 Configuration tag depending on your setup) with your GA4 Measurement ID. Trigger it on Initialization - All Pages. This provides the base for GA4 event tags. Audit the site first to avoid duplicate GA4 installation.

Step 3: Enable Built-In Variables

Go to Variables > Configure and enable click variables: Click Element, Click Classes, Click ID, Click URL, Click Text. These are essential for click-based triggers. For forms and custom data, you will also create Data Layer Variables.

Step 4: Track Button Clicks (Intent Actions)

Button clicks are useful intent signals, but they are not always conversions. For example, a "Submit" button click may happen even when validation fails. Track clicks as engagement/intent unless they represent a confirmed outcome. This matters because a site can have traffic but no leads when the wrong actions are counted.

Example: track a CTA button with class get-quote-btn.

  • Trigger type: Click - Just Links (or All Elements for buttons).
  • Condition: Click Classes contains get-quote-btn.
  • Tag: GA4 Event, event name cta_click.
  • Parameters: button_text, link_url, page_path.

Expected result: tag fires once on click. Verify: GTM Preview and GA4 DebugView.

Step 5: Track Phone, WhatsApp, and Email Clicks

Action Trigger Condition Suggested Event
Phone click Click URL starts with tel: phone_click
WhatsApp click Click URL contains wa.me or api.whatsapp.com whatsapp_click
Email click Click URL starts with mailto: email_click

These are high-intent interactions. For local businesses, they may be key events, but decide based on your reporting goals. Do not blindly mark every click as a primary conversion if it creates noisy optimization signals, which can lead you to pause or misjudge a PPC campaign.

Step 6: Track Form Submissions Reliably

This is where many implementations fail. A submit button click is not a successful lead. A successful lead should be tracked only after validation passes and the server confirms submission. Reliable tracking also supports connecting lead generation with CRM follow-up.

Option A: Thank-you page

If the form redirects to a unique confirmation page, fire a GA4 event on that page. Ensure the page is not accessible as a normal indexed page and handle refresh duplicates where possible.

Option B: Data layer push on success (recommended for AJAX)

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'form_submit_success',
  form_name: 'contact_form',
  form_location: window.location.pathname,
  lead_type: 'service_enquiry'
});

Where to place it: inside the success callback after server response confirms submission. Do not place it on button click. In GTM, create a Custom Event trigger for form_submit_success and a GA4 Event tag (e.g., generate_lead).

Step 7: Use Data Layer Variables and Parameters

Create Data Layer Variables in GTM for form_name, form_location, and lead_type. Add them as GA4 event parameters. This gives context in reports and helps distinguish lead sources/forms. Register custom dimensions in GA4 if you need them in reports.

Step 8: Test with GTM Preview and Tag Assistant

Click GTM Preview, connect your site, and perform the action. Check that the correct event appears in the left panel, the tag fired once, and variables have expected values. Test negative cases too: invalid form submission should not fire the success event.

Step 9: Verify in GA4 DebugView

In GA4 Admin, open DebugView and confirm the event name and parameters arrive. GTM firing alone is not enough; GA4 must receive the event. If GTM fires but DebugView is empty, check Measurement ID, consent, filters, or duplicate/conflicting scripts.

Step 10: Troubleshooting and Common Mistakes

Problem Cause Fix
Tag not firing Trigger condition mismatch Inspect Click URL/classes/text in Preview.
Duplicate events Double installation or multiple triggers Audit GTM/GA4 and trigger logic.
Undefined variable Variable not enabled or wrong key Enable built-in var or fix dataLayer key.
Lead counted on failed form Click trigger used as conversion Use success callback/dataLayer event.

Best Practices and Implementation Checklist

  • Track business outcomes, not every click.
  • Use clear naming conventions and a tracking plan.
  • Prefer stable selectors or data attributes.
  • Test in Preview and DebugView before publishing.
  • Document versions and changes.
  • Re-test after website redesigns or form changes.

GTM Account, Container, and Workspace Setup

Create a GTM account at tagmanager.google.com and add a Web container for your domain. Use a clear naming convention like "TDM - Web - Main". Inside the container, understand workspaces: they let you draft changes before publishing. For small teams, the default workspace is enough, but always review Workspace Changes before publishing.

Set container permissions appropriately. Not everyone needs publish access. A good workflow is: marketer/developer creates changes, another reviewer tests, then an authorized user publishes. Add version names and descriptions every time you publish so you can roll back quickly if needed.

Installing GTM on Laravel and Other Website Types

On Laravel, add the GTM head snippet to your main layout file (commonly resources/views/layouts/app.blade.php or a shared head include) so it appears on every page. Place the noscript iframe immediately after the opening <body> tag. If you use Blade components for layout, put it in the layout component used by all pages.

On WordPress, you can add it in the theme header.php or use a reputable GTM plugin. On Shopify, use theme.liquid. On custom sites, add to the shared header/footer template. Whichever platform you use, verify the container loads on all page types: home, service pages, blog, contact, thank-you pages.

Understanding Built-In Variables and Custom Variables

Built-in variables are quick to enable and cover common needs: Page URL, Page Path, Referrer, Click classes, Click ID, Click URL, Click Text, Form ID, etc. Enable only what you need, but make sure click/form variables are enabled before building triggers.

Custom variables include Data Layer Variables, JavaScript Variables, Lookup Tables, Constants, and DOM Element variables. For example, a Data Layer Variable named DLV - form_name reads form_name from the dataLayer. A Lookup Table can map page paths to service categories. Use clear names so teammates understand them.

Tracking Clicks with Better Selectors

Click Text is easy but fragile because text changes. Click Classes are better if stable. Best is a dedicated data attribute added by developers, such as data-gtm="whatsapp-header". In GTM, create a variable to read that attribute and use it in triggers. This makes tracking resilient to design changes.

Use Click - Just Links for links and All Elements for buttons or non-link elements. Test carefully: All Elements can fire on child elements, so check Click Element and conditions in Preview.

GA4 Event Tag Configuration

Create a GA4 Event tag for each meaningful action. Set Configuration Tag or Measurement ID, event name, and parameters. Use recommended event names where appropriate (generate_lead, file_download, etc.). Keep parameter names consistent. For example, always use form_name, not sometimes formName.

Before marking anything as a conversion in GA4, confirm it represents a confirmed outcome. A button click can be an event; a confirmed lead should be a key event candidate.

Debugging Workflow

When an event fails, debug in order: Is GTM installed? Did the expected event appear in Preview? Did the trigger conditions match? Are variables populated? Did the tag fire? Did GA4 DebugView receive it? This sequence prevents random guessing.

Common test cases: valid form submit, invalid form submit, page refresh on thank-you page, click on mobile viewport, click with consent accepted/rejected. Test all cases relevant to your implementation.

Conclusion

Reliable GTM event tracking comes from clear planning, precise triggers, structured data layer events, and disciplined testing. When you separate intent clicks from confirmed conversions and verify every change in DebugView, your analytics becomes a decision tool instead of a source of confusion. Clean tracking also makes it easier to identify website traffic drops and act on them.

FAQ

Frequently Asked Questions

Ready to Grow Your Business Online?

Trichy Digital Marketing helps businesses increase online visibility, generate quality leads, and boost sales through SEO, social media marketing, Google Ads, and branding solutions.

📍 Service Areas

Areas We Serve in Trichy

Trichy Digital Marketing provides professional digital marketing, website development, SEO, Google Ads, social media marketing, branding, and software development services to businesses across Trichy and nearby areas. Whether you're a startup, small business, educational institution, healthcare provider, retailer, or large enterprise, our team delivers tailored digital solutions to help you increase online visibility, generate quality leads, and grow your business.

We proudly serve clients in
Thillai Nagar
KK Nagar
Srirangam
Cantonment
Woraiyur
Tennur
Karumandapam
Edamalaipatti Pudur
Puthur
Crawford
BHEL Township
Ariyamangalam
Kattur
Ponmalai (Golden Rock)
Vayalur Road
Bharathidasan Salai
Chathiram Bus Stand
Palakkarai
Subramaniapuram
Sangiliyandapuram
Airport Area
Thiruverumbur
Samayapuram
Manachanallur
Panjappur
Navalpattu
Central Bus Stand
Trichy Railway Junction
Gandhi Market
Palpannai
Anna Nagar
Thiruvaikovil
TVS Tollgate
No. 1 Tollgate
Ponnagar
Beema Nagar
Kallukuzhi
Thuvakudi
Pudukottai Road
Thanjavur Road
Karur Bypass Road
Manapparai
✨ LIMITED TIME OFFER

YEAR-END SPECIAL OFFER 🎉

Grow Your Business on Social Media

₹12,000 Regular Price
₹6,500 Only
Social Media Marketing

Complete Social Media Marketing Package

✓ 1 Creative & Engaging Reel
✓ 10 Professional & Branded Posters
✓ Planned & Scheduled Posting
✓ Boosting for Better Reach
⏳ Offer valid till December 31st

Meta advertising charges are excluded.

Terms & Conditions Apply.

Get Started Today →