This article shows how to configure custom button tracking with Google Tag Manager and Google Analytics.
Pre-requisites
- Google Analytics measurement is created and the "Enhanced Measurement" feature is enabled.
- Google Analytics is connected with Google Tag Manager
(Optional) Website Configuration
1) Name the button for easier filtering in Google Tag Manager later. For example:
<button id="myButton">Hello</button>
<button class="track-this-button">World</button>
A common identifier would be the ID or the class name.
Google Tag Manager Configuration
1) Enable click-related built-in variables.
2) Create a new trigger for your button clicks. You can filter by specific criteria, such as button ID or class names.
3) Create a new tag to channel the event to Google Analytics and select the trigger in the previous step.
4) Click the preview button to test the changes you made.
5) Simulate the button click and confirm the event is being recorded.
6) Finally, you can click the submit button to publish your changes.
Observe the events in Google Analytics
1) You can now observe this event in Google Analytics. For example, in the realtime view: