The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

How to set up analytics code

Labels

This Discussion is public

Notifications

Where do I put 'onsubmit' code to track conversions? I can only use put 'onclick' code into the button code but it will track every click as a conversion even if the form is empty.
Here is an example:
<form action="" method="post" onsubmit="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;">
...
</form>

where can I find the code <form>...</ form>?

You can add the code to the submit button on the forms's Settings -> Customize HTML page. Scroll down to the bottom of the HTML and look for the submit button code. You can add it to the button HTML.

Event "onsubmit" applies to tag <form>, it doesn't work on button

Sorry, I misread your post. Formidable doesn’t have an user interface for this. You have to do this through code. I’m mobile right now without access to a computer. I’ll explain how to do this when I’m back in my office.

It would be great, thank you so much

This will add your code to the form. Add it to your theme's functions.php.

add_filter( 'frm_form_attributes', 'add_custom_form_attributes', 10, 2 );
function add_custom_form_attributes( $attributes, $form ){
if ( $form->id == 123 ) {
$attributes .= 'onsubmit="ym(XXXXXX, ' . "'reachGoal', 'TARGET_NAME'" . '); return true;"';
}

return $attributes;
}

Make sure you change the $form->id to match your form's id.

Thank you so much, you helped me a lot!

Discussion closed.