PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How to add javascript to Success Page of form?

  1. idealists
    Member

    I need to add Javascript script box to the Success Page of the form. Is there a hook (or something else?) I can use to do this? Could you also show me some example of the implementation code?
    I have tried adding the following script code to the "Confirmation message" in the Form Editor but it only gets triggered a fraction of the times it is supposed to be ( Eg. I get 20 enquires[form fills] in 1 day, but analytics script only gets triggered 3-4 times. This is why I want to try something different, and add the script code below using a hook (or whatever the term is).

    <script type="text/javascript">
    var funnel_url="/applications/debt-consolidation-loan?step=complete";
    _gaq.push(['_trackPageview',funnel_url]);
    </script>

    Many thanks.
    ps. running Gravity Forms 1.3.13.1

    Posted 13 years ago on Tuesday December 7, 2010 | Permalink
  2. There is currently no hook on the confirmation message but we will look into adding some.

    Adding it to the confirmation message itself should work, whatever you enter in the confirmation message will be displayed when the form is submitted so if you enter Javascript it will be executed. If it isn't executing properly then it could be a problem with the Javascript not being utilized that way.

    One thing you can do is create a WordPress Page to use as the confirmation and redirect to that page as the Thank you rather than using the built in confirmation message. Then you can put whatever you want on that page as far as scripts go.

    Also I see you are running Gravity Forms v1.3.13.1, you may want to upgrade to the latest version of Gravity Forms. We always recommend running the latest version for security and bug fix reasons. Just like WordPress, you should always keep up to date with the latest version for stability reasons... not just new features.

    Posted 13 years ago on Tuesday December 7, 2010 | Permalink
  3. idealists
    Member

    Hi Carl, thank you for your reply.
    I intend to update WP and Gravity Forms, and I'm just worried something may break if I do :) Silly me I know, lol

    I would be interested in doing your suggestion :
    "One thing you can do is create a WordPress Page to use as the confirmation and redirect to that page as the Thank you rather than using the built in confirmation message"

    How do I go about using a WP page as the confirmation page?

    Many thanks

    Posted 13 years ago on Thursday December 9, 2010 | Permalink
  4. You would create a WordPress page just like any page, then place your thank you message in it. Go to your forms, edit the form you want to change and go to Form Settings (hover over the form title/form description area and click Edit) then go to the Confirmation page. There is an option to go to a Page when the form is submitted, choose this and select the page you created.

    You can optionally choose Redirect and put the full path URL to the page (Ex. http://path.com/path/to/page) and then also pass form field values to the page using the redirect querystring builder. HOWEVER if you do this you would have to setup a custom page template and use PHP to display those query string values so this one is a little more complex.

    Posted 13 years ago on Thursday December 9, 2010 | Permalink