In this post I’ll show you how to track button clicks by using Google Tag Manager to send events to Google Analytics.

1) Set up your click trigger

First set up a generic click trigger. We’ll be updating this later.

  1. Click Trigger
  2. Create a new Trigger
  3. Choose All Elements under Click
  4. Fire the trigger on All Clicks
  5. Save

Open up the GTM preview panel on your website and click the variables tab.

Click the button you would like to track. You can now see the variables that define the specific button click. We’ll use these variables to update our generic click trigger so that it that only tracks your specific button clicks.


2) Update your generic click trigger

  1. Give your generic click trigger a suitable name
  2. Update to Fire on Some Clicks.
  3. Choose Click ID > Containing > [Your button ID] eg my-button

3) Create a tag that sends event data to Google Analytics

  1. Go to Tags
  2. Create New tag
  3. Choose the Universal Google Analytics tag type
  4. Enter your Google analytics tracking ID
  5. Choose the Event Track Type
  6. Enter the Category, Action and Label
  7. Under the Triggering section select your Click Trigger
  8. Save

I’ve already saved my Google Analytics ID in a constant variable and recommend you do the same. This way if you ever need to update the ID you only have to update one variable.


4) Check your tag is working

Open the preview and debug window and make sure that the tag is firing correctly.

Open Google Analytics and go to Real-time > Events where you will be able to see your button clicks in real time.

Als Johnstone

alsjohnstone