• Narthur

    (@narthur)


    I’m trying to fire a Google Analytics event on form submission. I tried putting some JavaScript in the thank you message, but it seams to run before the user submits the form.

    Is there anyway I can tie some JavaScript to form submission?

    https://ww.wp.xz.cn/plugins/usernoise/

Viewing 1 replies (of 1 total)
  • Thread Starter Narthur

    (@narthur)

    I tried this:

    jQuery(document).on('click','#un-feedback-submit',function() {
    	console.log('Ow!');
    });

    Then I realized the form is in an iframe, so that doesn’t work.

    I tried this in my theme’s functions:

    function trackFeedbackSubmission() {
    	echo '<script type="text/javascript">
    		ga("send","event","form","contact");
    		console.log("Submission tracking attempted");
    	</script>';
    }
    add_action('un_feedback_created','trackFeedbackSubmission');

    Which results in this error in the JavaScript console on form submission:

    SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Viewing 1 replies (of 1 total)

The topic ‘Run JavaScript On Submission?’ is closed to new replies.