How can I add Google Analytics event tracking in CFv5?

Here's how one user solved this problem. You can easily attach the code to the submit button but then it triggers even if the form validation fails so you can get multiple results sent to GA. The approach here fires the tracking code only after the form validation succeeds.

In the form Setup tab open the HTML (Render Form) action. Usually this is in the On Load event, unless you are using a multi-page form in which case you want the one in the last page to be loaded.

and add this attribute to the Form Tag Attachment box

data-gvalidate_success='ga_track'

Save this action then drag in a Load JS action to the same event and add this code, changing the variables to meet our needs:

function ga_track(event, form){
  ga('send', 'event', 'newsletter', 'click-newsletter', 'some text here');
} 

Save and test

VPS & Email Hosting 20% discount
hostinger