WordPress.org

Support

Support » How-To and Troubleshooting » [Plugin: Ninja Forms Pro] Adding Javascript onSubmit action with Ajax forms

[Plugin: Ninja Forms Pro] Adding Javascript onSubmit action with Ajax forms

  • I’m currently configured to “Submit via Ajax.” which is my preferred user experience. This means that I need to add a javascript onsubmit action to call Google analytics to track successful submissions in my goal funnel.

    If its possible to add an onsubmit action to the Ninja Forms Lite form tag, how do I do it?

    If it isn’t possible, do I have any alternatives to deselecting “sumbit via Ajax” and creating a “success” page?

    http://wordpress.org/extend/plugins/ninja-forms/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey pidginbil,

    You can do that in your own JS file, you just want to add an action to the “onclick” event of the submit button ID for your form.

    Thanks Kevin … I’m a little bit outside my comfort zone with JavaScript, so please help me out a bit if you can.

    button field ID: 9
    Using Inspect element, the Button HTML is:

    <input id=”ninja_submit” name=”ninja_submit” type=”submit” value=” Submit ” class=” “>

    the JavaScript I’d like to call is for google analytics:

    onsubmit=”pageTracker._trackPageview(‘/pagename’); return false;”

    Where pageTracker._trackPageview is defined elsewhere on the page:

    <script type=”text/javascript”>
    var pageTracker = _gat._getTracker(“UA-######-#”);
    pageTracker._initData();
    pageTracker._trackPageview();
    </script>

    I do know how to add a javascript snippet to a wordpress page. What this untrained noob don’t understand is how to wrap the onsubmit event in a way that ties it to the button ID.

    Thanks

    BILL

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Ninja Forms Pro] Adding Javascript onSubmit action with Ajax forms’ is closed to new replies.
Skip to toolbar