AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4.9K members online now
4.9K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

How to track form submission

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Dear Friends,

 

I wanted to track a simple contact us form submission and the code I used for this was,

 

onsubmit = "ga('send', 'event', 'Contact Form Submission', 'post', location.pathname, {
nonInteraction: true});"

 

It doesn't work and gives this error,

Uncaught SyntaxError: Unexpected token ILLEGAL  VM300:1

 

Everything else in the Google Analytics account is working fine. May be because the developer has implemented the code inside a function?

 

any help regarding this would be highly appreciated.

 

Thank you

1 Expert replyverified_user

Re: How to track form submission

Top Contributor
# 2
Top Contributor
Hi,

Your code is ok, the problem must be with its implementation. If you could show me the form I'd be glad to look into it for you.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to track form submission

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you very much Arnold M Smiley Happy

here is the form (hope this is what you asked for)

<form action="/contact-us/#wpcf7-f2017-p2044-o1" method="post" class="wpcf7-form" novalidate="novalidate">
<div style="display: none;">
<input type="hidden" name="_wpcf7" value="2017">
<input type="hidden" name="_wpcf7_version" value="4.4.2">
<input type="hidden" name="_wpcf7_locale" value="en_US">
<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f2017-p2044-o1">
<input type="hidden" name="_wpnonce" value="e114ef538d">
</div>
<div id="commentform">
<p class="one-third"><label>Your Name *</label><span class="wpcf7-form-control-wrap your-name"><input type="text" name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span> </p>
<p class="one-third"><label>Your Email *</label><span class="wpcf7-form-control-wrap your-email"><input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false"></span> </p>
<p class="one-third"><label>Subject</label><span class="wpcf7-form-control-wrap your-subject"><input type="text" name="your-subject" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span> </p>
<p><label>Your Message *</label><span class="wpcf7-form-control-wrap your-message"><textarea name="your-message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea" aria-invalid="false"></textarea></span> </p>
<p class="focus"><input type="submit" value="Send Message" class="wpcf7-form-control wpcf7-submit btn-ripple"><img class="ajax-loader" src="http://www.nkarmice.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden;"></p>
</div>
<div class="wpcf7-response-output wpcf7-display-none"></div></form>