Time To Start Tracking Your Button Clicks In Google Tag Manager

Google Tag Manager (GTM) is a fabulous tool to house all your website or mobile app tags and code snippets. While the basics are fairly easy to follow and implement, some of the more advanced capabilities can seem daunting and overwhelming. I recently tackled learning how to track button clicks and am breaking it down into simple, easy-to-follow steps so you can implement this feature as well.

Which Buttons Might I Want to Track on My Website?

Here are just a few examples of buttons you might want to track:

  • Navigation Bar
  • Subscribe/Sign-Up
  • Learn More
  • PDF Downloads
  • Affiliate Marketing Partners
  • Third-Party Links

How Google Tag Manager Can Track Clicks

There are two ways that GTM can track events like clicks. One is using Data Layer Event Code. The other is Auto-Event Tracking. I found several ways to configure your tags and triggers and I’m going to outline the one I found the simplest using auto-event tracking.

Step One: Make Sure Clicks Are Enabled in the Built-In Variables Menu

Since events are triggered based on clicks, we need to make sure that click variables are selected to be captured.

  1. In GTM, select “Variables” on the Left Side column below Triggers
  2. Select “Configure”
  3. Scroll down to Clicks and select all of the options

Step 2: Create a Site-Wide Click Trigger

This step is to help us learn how to identify the click event or button we want to track.

  1. In GTM, click on “Triggers”
  2. Click “New”
  3. Name the Trigger in a way that makes sense to you. I’m choosing “Site-Wide Clicks”
  4. For your trigger type, go to Clicks, then select “All Elements”
  5. Select “All Clicks” since this is your site-wide click trigger
  6. Hit “Save”

Step 3: Learn How Your Website Captures Your Button

Now that we have told GTM to see all the clicks on the site, we’ll use the Preview Mode to see what happens when we actually click on the button what we’re trying to track. For this blog post, I’m going to capture Newsletter Sign-ups. Hang in here with me – this is the trickiest part.

  1. In GTM, publish your work. This allows what we completed from the first to steps to become active.
  2. Next, in the GTM Workspace tab, click the Preview button. This will allow us to peak in on which Tags and Triggers are firing on our website.
  3. Go to your website. You should see a GTM box on the lower portion of your site.
  4. Navigate to the button you want to track and click it. Each click will generate new steps in the Summary section.
  5. Because you clicked on your button, you’ll go to the next screen based on what you clicked. Just hit the back button. The number of actions in the Summary to the left will have increased.
  6. Go down until you see one that says “gtm.click” and select it. If the button you are tracking is on your home page, you’ll have only clicked once and it should be easy to spot. If you had to navigate through your site to get to the button, you’ll look for the “gtm.click” that is highest in the summary since that’s the last action you took. We can double check that this looks correct by selecting the Variables tab in the GTM section. Look at the “Click Text” variable to make sure it matches your button.
  7. Find the “Click Classes” variable. This tells you the code for how this particular event is named. Copy the code. In my example below, it’s “btn btn-teal”. Do not include the word “button”.

 

 

Step 4: Redefine Your Site Wide Click Trigger

Now that we know how our website defines the button we want to track, we’re going to change the existing click trigger to make it specific for the button we’re tracking.

  1. Go back to GTM and click on your Site-Wide Trigger
  2. Rename it for the button you’re tracking. For me, this will be “Subscribe”
  3. Instead of having “All Clicks” selected, now choose “Some Clicks”
  4. In the left-most drop-down menu, select “Click Classes”
  5. Select “contains” from the middle drop-down menu
  6. In the right most drop-down menu, paste the code you copied above
  7. Click “Save”

 

Step 5:  Add the Trigger to a Tag

Now that we have the correct trigger, we must assign it to a tag.

  1. Click “Tags”
  2. Select “New”
  3. Input a name that makes the most sense to you. I like to be as clear as possible, so I’m choosing “Analytics – Event – Subscribe Button”
  4. For Tag Type, choose “Universal Analytics”
  5. For Track Type, select “Event”
  6. There isn’t a right or wrong way to name the fields here, but complete this as it makes the most sense for your button. Here is how I completed it for this example:
    • Category: Button Clicks
    • Action: Click
    • Label: Click on the lego like icon and select “Page Path”
  7. In the Google Analytics Settings Box, select the drop down. If you don’t have a Tracking ID set-up, you’ll need to create one
    • Click “New”
    • Name the Untitled Variable. I think “Analytics ID” makes sense
    • Enter in your Universal Analytics Account number. You can find this in Google Analytics. It’s the number that begins with “UA-“ and a series of numbers.
    • Leave “Cookie Domain” as “auto”
    • Click “Save”. This takes you back to the Tag Screen
  8. Almost there! Now we must add our button trigger to this tag. Click on the trigger icon below
  9. Select your button trigger
  10. Hit “Save”

Step 6: Let’s Make Sure it Works!

  1. Click “Refresh” in the Preview box.
  2. Go back to your website and refresh it. You should still see the Analytics box at the bottom.
  3. Click the button you are tracking.
  4. If you are taken to the next page again, click the back button.
  5. In the summary section, find your click again by selecting “gtm.click”. You should see your Google Analytics Trigger Appear. Success!

 

  1. Don’t forget to go back to GTM and publish everything again!

Step 7:  One Last Double Check

  1. Go into your Analytics Account.
  2. In the Real-Time Section, go down to “Events”.
  3. You should see your event there. If you don’t, go back to GTM to make sure you published everything. Then refresh your site and click on your button again. Check Analytics again to see if the event is now there. If you still don’t see it, go back through these steps to see if you can catch any steps you may have missed.

I don’t consider myself a GTM pro by any means, so I know I’ll be referring to this guide in the future. I hope you find it helpful as well!  If you are looking for other GTM triggers to test, check out this blog for some ideas. We also have another post for you which includes a different way to track PDF downloads.

Which buttons do you track in GTM?  Comment below to share!

Comments (5)

  1. I’m so glad! You’re very welcome. I have revisited this blog post several times myself because this type of tracking is very useful.

Leave a Reply