How to Track Button Clicks with Google Tag Manager
Tracking button clicks with Google Tag Manager can be helpful if you do not have access to your backend. It’s also helpful if you use plugins that do not give you the option to add tracking.
For Media Cause client, Global Down Syndrome Foundation, we wanted to track petition signatures. The petition uses a WordPress plugin called “SpeakOut! Email Petitions,” which does not allow for install tracking.
The solution: Track conversions (button clicks) with Google Tag Manager (GTM).
Before You Begin
- Create a GTM account.
- Install the GTM pixels on the page with the button (GTM tells you to add it to all pages). This is the only time you need backend access.
- Create and test a generic click trigger
- Filter the click trigger to the button you want to track
- Create an event tag based on the trigger
- First, we want to create a generic click trigger. In GTM, go to Triggers > New.
- Create a trigger called Generic Click Trigger:
- Click on the Trigger Configuration box > select All Elements under Click > select All Clicks.
- After you save, we now need to filter the clicks to our button.
- We need to make sure GTM will track click variables, because they’ll be our filters. Go to Variables.
- Click “Configure” under Built-in Variables:
- Scroll down and check all the checkboxes under Clicks:
- Now, on the top right of the screen, click the down arrow next to the Publish button > click Preview.
- In a new tab, open the page with the button on it. If you already have it open, refresh. You should see the GTM console at the bottom of the screen.
- Notice the Summary on the left. Notice how many elements it has. We are going to click the button to see what new elements show up in the Summary.
- Fill out your form if you have one.
- When you are ready to click your button, hold down your keyboard’s COMMAND button and click the button. The COMMAND key opens the link in a new tab.
- In your original tab, the Summary should have new elements. My new one is gtm.click #5:It might be hard to tell which new element was triggered by your button click. Click on the variables tab to see which gtm.click is the one for your button. For me, I can tell #5 is the correct one because the “Click Text” is ADD YOUR NAME, which matches the button. In a nutshell, these variables are associated with your button. Now, we want to filter our Generic Click Trigger using these variables.
- Back in your GTM tab, go to Triggers > click on your Generic Click Trigger. Re-name it to what you want to track. I titled mine “Signed Research Funding Petition.”
- Under Trigger Configuration, change All Clicks to Some Clicks. Then when it comes to the dropdown bar, I’m choosing Click Text and pasting the Click Text that the Variables box gave me:
If, for some reason, you don’t have anything for Click Text, you can also use Click Classes and copy the appropriate value.
- Now we want to create our actual event tracking tags. Go to Tags > click New.
- Name your tag. I named mine, “GA – Event – Signed Research Funding Petition”.
- Click on the Tag Configuration box > your Tag Type should be Universal Analytics. Put your Google Analytics ID. This can be found by going to Google Analytics > clicking your property > Admin > Property Settings > copy your Tracking ID. Copy the whole thing, including “UA-”
- Choose Event as your Track Type.
- Set your event tags. What events do you want to fire off when someone clicks the button?
- Click the Triggering box. You should see the trigger you created. Mine is “Signed Research Funding Petition.” Choose that.
- Now we want to test this out again but with the new event tag! Click Refresh to refresh our preview mode:
- Refresh the tab you have open with your button.
- Click on your button (remember to hold COMMAND so your current tab doesn’t change).
- View the “Tag” tab and the button click should have triggered a gtm.click variable with your new tag:
- Go into Google Analytics > Real-time > Events, and you should see it. Excuse mine for having two:
- BONUS! You can then go on to add this event as a goal in Google Analytics, so you can see the conversion rates between different sources.
Tracking your conversions is key to success. If your organization needs help tracking goals and conversions, get in touch to see how we can help you.