简体   繁体   中英

Google Analytics - track form submission

I know this is possible to track how many people have actually clicked on the submit button of form, but my form has a validation, if someones click on submit without entering a value, GA will count this, but this is not a real submission.

How do i track how many people have actually submitted the form using GA?

please let me know

thanks

You can output the GA code on success of your post request. A basic in page php example would be something like this:

if(isset($_POST)){
    echo "<script>_gaq.push(['_trackEvent', 'Contact', 'Inquiry', 'Inquiry Form', 0, false]);<script>";
}

You can also use the onSubmit function. A client side solution would be this:

<form id="form-name" name="form-name" action="submission-url-goes-here" method="post" 
 onSubmit="_gaq.push(['_trackEvent', 'FormName', 'FormSubmit', 'FormSubmissionCompleted']);">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM