[Answer]-Google Analytics event tracking on a button

1👍

Add the ga event tracking code to the change() function. You can include the doctor.clinic.contact_no as one of the parameters to the _trackEvent function, here it would show under “label”.

If you are using classic ga (i.e. have ga.js)

function change() 
{
var elem = document.getElementById("myButton1");
elem.value = "" + {{doctor.clinic.contact_no}};
_gaq.push(['_trackEvent', 'phone', 'show','{{doctor.clinic.contact_no}}',, false]);
}

With Universal analytics (analytics.js) it would be:

function change() 
{
var elem = document.getElementById("myButton1");
elem.value = "" + {{doctor.clinic.contact_no}};
ga('send', 'event', 'phone', 'show','{{doctor.clinic.contact_no}}');
}

Make sure you have the basic tracking code in place as well.

👤Olss

Leave a comment