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
- 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.
- In GTM, select “Variables” on the Left Side column below Triggers
- Select “Configure”
- 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.
- In GTM, click on “Triggers”
- Click “New”
- Name the Trigger in a way that makes sense to you. I’m choosing “Site-Wide Clicks”
- For your trigger type, go to Clicks, then select “All Elements”
- Select “All Clicks” since this is your site-wide click trigger
- 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.
- In GTM, publish your work. This allows what we completed from the first to steps to become active.
- 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.
- Go to your website. You should see a GTM box on the lower portion of your site.
- Navigate to the button you want to track and click it. Each click will generate new steps in the Summary section.
- 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.
- 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.
- 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.
- Go back to GTM and click on your Site-Wide Trigger
- Rename it for the button you’re tracking. For me, this will be “Subscribe”
- Instead of having “All Clicks” selected, now choose “Some Clicks”
- In the left-most drop-down menu, select “Click Classes”
- Select “contains” from the middle drop-down menu
- In the right most drop-down menu, paste the code you copied above
- Click “Save”
Step 5: Add the Trigger to a Tag
Now that we have the correct trigger, we must assign it to a tag.
- Click “Tags”
- Select “New”
- 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”
- For Tag Type, choose “Universal Analytics”
- For Track Type, select “Event”
- 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”
- 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
- Almost there! Now we must add our button trigger to this tag. Click on the trigger icon below
- Select your button trigger
- Hit “Save”
Step 6: Let’s Make Sure it Works!
- Click “Refresh” in the Preview box.
- Go back to your website and refresh it. You should still see the Analytics box at the bottom.
- Click the button you are tracking.
- If you are taken to the next page again, click the back button.
- In the summary section, find your click again by selecting “gtm.click”. You should see your Google Analytics Trigger Appear. Success!
- Don’t forget to go back to GTM and publish everything again!
Step 7: One Last Double Check
- Go into your Analytics Account.
- In the Real-Time Section, go down to “Events”.
- 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!