OnClick Event Tracking in Google Analytics
Trying to get onClick event tracking for various buttons working through a 7 step form that has a static URL with Dynamic content inside (need the events to know each steps information).
Here is the code I'm currently using (it's not pushing the event to GA):
<script> |
|
|
|
$(function () { |
|
$('#save-loader').hide(); |
|
|
|
$('#Step2NextButton').click(function () { |
|
ga('send', 'event', 'BYS', 'Next', 'System Type'); |
|
}); |
|
}); |
|
|
|
</script> |
The code I'm about to try is:
<script>
$function () {
$('#save-load').hide();
$('#Step2NextButton').on( "click", function () {
ga('send', 'event', 'BYS', 'Next', 'System Type');
});
</script>
Are either right?
The info behind the button is:
<input id="Step2NextButton" class="btn btn-primary btn-large" type="submit" onclick="$('body, html').animate({scrollTop : $('#sub-scroll-top').offset().top}, 400); return true;" value="Next" name="ctl00$ctl00$MainContent$SubMainContent$Step2NextButton">
</input>