• Resolved Michael v.d. Berg

    (@michaelvdberg)


    I have a question about the redirect function of Contact For 7. I used the on_sent_ok: “location = function, but this function will be out of date at the end of this year.

    So I followed the guide at your website to replace this code with on_sent_ok: “ga( ‘send’, ‘event’, ‘Contact Form’, ‘submit’ );”, and added in the bottom of the functions.php file the other code:

    add_action( ‘wp_footer’, ‘mycustom_wp_footer’ );

    function mycustom_wp_footer() {
    ?>
    <script type=”text/javascript”>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    ga( ‘send’, ‘event’, ‘Contact Form’, ‘submit’ );
    }, false );
    </script>
    <?php
    }

    In the header.php I put the other script code to redirect to the right page:
    <script>
    document.addEventListener( ‘wpcf7mailsent’, function( event ) {
    location = ‘http://www.example.com/&#8217;;
    }, false );
    </script>

    But when I saved it, I got the 500 error message from the browser. When I delete the codes, everything works fine again. How can I replace this code for the correctly one to redirect the contact forms to the thank you page?

Viewing 1 replies (of 1 total)
  • Thread Starter Michael v.d. Berg

    (@michaelvdberg)

    I added the latest script to my website and the ga( ‘send’, ‘event’, ‘Contact Form’, ‘submit’ ); to my Additional Settings tab of the contact form. It works fine without any error or failure message 🙂

Viewing 1 replies (of 1 total)

The topic ‘Redirect after succesfully’ is closed to new replies.