'Onclick Button Event Tracking for Google Analytics
I want to track when a button has been clicked on. I have tried multiple ways of doing this and nothing shows up in my Google Analytics. What am I doing wrong?
<a href="#Reserve" class="btn-large btn-primary text-white" onClick="ga([ '_trackEvent', 'button', 'click', 'reserve now' ]);" >RESERVE NOW<span class="glyphicon glyphicon-menu-right pull-right"></span></a>
Solution 1:[1]
Try this:
<a onclick="ga('send', 'event', 'type_here_your_category_event', 'type_here_your_event_name');" href="#">Hit here</a>
For buttons it's work as well.
<button onclick="ga('send', 'event', 'type_here_your_category_event', 'type_here_your_event_name');">Hit here</button>
type_here_your_category_event - just type here your cat name
type_here_your_event_name - detail name of event,
send & event - live as is.
It depends on which button you want to hook this event.
Please see Event Tracking from Google Analytics Docs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stefan Bols |
