Is this the proper way to trigger a button click event to be tracked in Google Analytics? I’m working in wordpress and this seems easier and simpler to maintain than editing the theme files. I would insert the second script below with a plugin that allows you to do that.

Analytics code:


  ga('create', 'XX-XXXXXXXX-X', 'auto');
  ga('send', 'pageview');

Submit button click event for tracking:

document.getElementById("button_id").onclick = function ga('send', 'event', 'ButtonClick', 'Click', 'ButtonClicked', '0');

Read more here: Calling Google Analytics Goal Tracking Function with Javascript onClick event


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: