How to Add Redirect for Contact form 7 to thank you page

Contact Form 7 is one of the most popular form plugins for WordPress, allowing users to create and manage forms easily. However, by default, it does not include a built-in redirection feature after form submission. Redirecting users to a thank you page can improve user experience, track conversions, and enhance engagement. In this guide, we will show you different methods to add a redirect to a thank you page after form submission in Contact Form 7.

Method 1: Using Additional Settings (Deprecated Method)

Contact Form 7 previously supported a simple method using the Additional Settings option, but this approach is now deprecated. If you are using an older version of Contact Form 7, follow these steps:

  1. Log in to your WordPress Dashboard.
  2. Go to Contact → Contact Forms.
  3. Click on the form you want to edit.
  4. Open the Additional Settings tab.
  5. Add the following line:
on_sent_ok: "location.replace('https://yourwebsite.com/thank-you/');"
  1. Replace https://yourwebsite.com/thank-you/ with the actual URL of your thank you page.
  2. Save the form.

Note: This method is outdated and may not work in the latest versions of Contact Form 7.

Method 2: Using JavaScript (Recommended)

A more modern approach is to use JavaScript to handle redirection after form submission.

Steps:

  1. Open your WordPress Dashboard.
  2. Navigate to Appearance → Theme File Editor.
  3. Locate and open the footer.php file or add the script in a custom JavaScript file.
  4. Insert the following script inside the <script> tags:
document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('wpcf7mailsent', function(event) {
        window.location.href = "https://yourwebsite.com/thank-you/";
    }, false);
});
  1. Replace https://yourwebsite.com/thank-you/ with your thank you page URL.
  2. Save the changes.

This method ensures smooth redirection and is compatible with the latest Contact Form 7 versions.

Method 3: Using a Plugin (Easiest Method)

If you prefer a plugin-based solution, there are several plugins available that provide redirection features for Contact Form 7.

Recommended Plugins:

Redirection for Contact Form 7 – Allows easy setup of redirections.

Steps for Redirection for Contact Form 7 Plugin:

  1. Install and activate the Redirection for Contact Form 7 plugin.
  2. Go to Contact → Redirect Settings.
  3. Choose the form you want to modify.
  4. Enable redirection and enter the URL of your thank you page.
  5. Save the settings.

This method is beginner-friendly and requires no coding knowledge.

Final Thoughts

Redirecting users to a thank you page after submitting a form improves user engagement and conversion tracking. While the on_sent_ok method is deprecated, the JavaScript (wpcf7mailsent) approach is the most reliable method. If you prefer a hassle-free solution, using a plugin is the easiest way to implement redirection.

We hope this guide helps you set up redirection in Contact Form 7 effectively. Let us know in the comments if you have any questions!