Discover how to easily track button clicks in Google Analytics using Google Tag Manager.
Let's just start off by saying Tag Manager is great and we're going to show you how easy it is to track button clicks or links on your site. This post will detail how to create the trigger. Once you've done that go this this how-to which will show you how to create the Event in Tag Manager for Google Analytics 4 and the Event and Goal in Google Universal Analytics if you'd like to do that.
To start off you're going to need Tag Manager installed and Google Analytics running in Tag Manager. For our Webflow fans, Milk Moon Studio is a small Webflow Studio and we have a Tag Manager how-to just for you over here. And for everyone else, and the Webflow fans, a how-to on adding GA to Tag Manager here.
Step 1 - Create a click trigger using click text
Head to your Tag Manager Container, hit Triggers and then New.
Give your Trigger a name, we'll be tracking our Contact Us button click.
Select Click - All Elements as the Trigger Type.
Select Some Clicks.
Our button says Contact Us, so we're going to select Click Text from the dropdown, then Contains, and add Contact Us.
Save and you're done.
To make this work just Submit and Publish. It won't do anything but fire when you click, to create your event go to the next how-to.
But let's say you don't want to track using Click Text, you could use some of the other variables (we have a separate post for Form Submission tracking), go try them out, things like Click Classes etc. are fairly easy to use, but let's look at tracking specific link clicks.
Step 2 - Tracking link clicks
Okay, so in our case we have just added a new portfolio item and we'd like to track how many folks clicked on the link to our client's site. We're going to set up a link click trigger.
Again, go to Trigger and hit new, give the Trigger a name, select Click - Just Links. We want this because it's a link in the copy of the of our portfolio post and we'd just like to track links to the client's site.
Select Some Link Clicks, then from the dropdown select Click URL, then Contains is fine and paste in the link you used on the site.
Save, Submit and Publish. You're done, to create the event and link the trigger head here.
Remember to always Submit and Publish, and if you have issues or questions hit us up in the comments. But that's the long and short of how to track button clicks..