AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
2.1K members online now
2.1K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Custom button&event tracking

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

Clients webpage has many buttons, but they want to track only one specific button. As I understand I need to add event tracking on the button and code would look like this:

 

ga('send', {

  hitType: 'event',
  eventCategory: 'Button',
  eventAction: 'Click',
  });

 

But I also found that other coders to track specific button are using this one:

 

<button type="button" onclick="ga('send', 'event', 'button', 'click', 'phone-number-middle');" id="call-phone-middle"><i class="fa fa-phone"></i>Call us</button>

 

Could you share your best practises of tracking specific button? Thank you.

Darius

 

Re: Custom button&event tracking

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆
Hi,

If you are familiar with GA, then you can use, ga('send', 'event', 'button', 'click', 'phone-number-middle'), otherwise use the other one.

Will recommend to use the below one, will have slight better performance than the above one.

ga('send', {
hitType: 'event',
eventCategory: 'Button',
eventAction: 'Click',
});

Here you are setting all the values in am object and then sending the object.

For better understanding, go through the below link

https://developers.google.com/analytics/devguides/collection/analyticsjs/events

Sam.