Redirect Contact Form 7 to thank you page

Redirect Contact Form 7 to thank you page

The Contact Form 7 plugin is one of the most popular contact form plugins for WordPress. It allows you to easily create and manage contact forms for your website. However, after a user submits a form, they are usually taken to a default thank-you message, which can be a bit uninspiring. In this tutorial, we’ll show you how to redirect Contact Form 7 to a thank you page in WordPress.

  1. Create a Thank You Page

    The first step is to create a thank you page. This page will be the destination for your Contact Form 7 form submissions. To create a thank you page, go to the WordPress dashboard, click on “Pages”, and then click on “Add New”. Give your page a title, such as “Thank You”, and add any content you want to display on the page. Once you have finished, click on “Publish” to publish the page.

  2. Copy the URL of the Thank You Page

    Once you have created your thank you page, you will need to copy its URL. To do this, go to the WordPress dashboard, click on “Pages”, and then click on the “Thank You” page. From here, you can copy the URL from the address bar at the top of your browser.

  3. Add a Redirection to Your Contact Form 7 Form

    To redirect Contact Form 7 to your thank you page, you will need to add a redirection in your header. To do this, you can use any plugin like Simple Custom CSS and JS, or Insert Header and Footer . You can put the below code in the header section to make it work.

    <script>
    document.addEventListener( 'wpcf7mailsent', function( event ) {
    location = 'https://www.example.com/thank-you/';
    }, false );
    </script>
    

    Note: Replace “https://www.example.com/thank-you/” with the URL of your thank you page.

  4. Save Your Form

    Once you have added the redirection code, click on “Save”. Your form will now redirect to the thank you page after a user submits the form.

Conclusion
Redirecting Contact Form 7 to a thank you page is a great way to provide users with a more engaging and personalized experience after they submit a form. By redirecting to a custom thank you page, you can show users a message of gratitude, provide them with additional information, or even offer them a special offer. With just a few simple steps, you can redirect Contact Form 7 to a thank you page and take your website to the next level.