0

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>
Alexander O'Mara
  • 58,688
  • 18
  • 163
  • 171
Chris W
  • 1
  • 1
  • 1
  • RESERVE NOW – Chris W Jul 19 '17 at 14:55
  • 4
    Possible duplicate of [Track event in google analytics upon clicking form submit](https://stackoverflow.com/questions/4086587/track-event-in-google-analytics-upon-clicking-form-submit) – Dezza Jul 19 '17 at 15:08

1 Answers1

0

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

Stefan Bols
  • 365
  • 1
  • 4
  • 8
Tsurule Vol
  • 452
  • 2
  • 6