Buy Now
Sign in

FAQ search

How can I add Google Analytics event tracking in CFv5?

Published: Saturday, 13 December 2014 16:23

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


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