Google Tag Manager v2 allows website owners to easily track button clicks by setting up a tag to pull data in Google Analytics. You can easily complete this in less than 10 minutes, 5 if you are fast 🙂 Follow the instruction below. To learn Google Tage Manager quickly, check out Google Tag Manager for Beginners Plus.
To track button clicks in GTM follow the instructions below:
The process is split into 3 parts:
- Build a Click Trigger
- Click Trigger Configuration
- Linking to the Google Analytics Tag
Build the Generic Click Trigger:
In order for us to track button clicks we must trigger this event so that this data can be passed to Google Analytics. We know that we want to track button clicks but we don’t know the the data markup that defines that each specific button click.
So the first step is to build a generic click trigger so that an event can be created in GTM. You can build a generic click trigger now and define it later. Here is how:
- Open GTM
- Click Trigger
- Create a new Trigger
- Choose Click for the event
- Choose All Elements when configuring
- For Fire On, choose All Clicks
- Create Trigger
Identify the HTML markup of the button click by using the GTM preview to view the variables that define your click. You will need to refresh the page and then click the button. In the event summary find the gtmclick event Reveal it’s variables by clicking the variable tab.
Defining the trigger
We can use the information to transform the generic click trigger into a specific trigger. For example the click class associated with the trigger is “search-button”. Use this information to redefine the click trigger.
- Choose the Generic Click Trigger.
- Rename it to a specific name
- Change to Fire on Some Clicks.
- Choose Click Classes and within containing add “the button name. In this case, I’m using the name “search_button”.
Attaching the Trigger to Google Analytics tag
- Open GTM, create a tag
- Choose the Google Analytics Template
- For tag type, choose Universal
- Click Configure Tag and add your Google analytics tracking ID
- For the Track Type, Choose Event
- Name The Category, Action and Label.
- For the Value, you will need to define this for my purposes I chose page path because I would like know the page where the click occurred
- For the Fire On rule, choose the More option and choose your defined click trigger.
- Create Tag
Lastly open your Google Tag Manager preview mode and test the tag. After click the button, you will see that the tag is firing currently.
For a quality check you to view whether this information is being pulled into the Google Analytics events. We check the real time events to see if the data can be tracked in analytics.
How to Track Button Clicks in Real Time using Google Analytics
In order to see whether the button tracking is working correctly, you will need to check your analytics account to ensure that the data has been based correctly via the tag. To this you can look into the event section to discover if the button click can be found in the real time data events.
- Real Time –> Events