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:
- Log in to your WordPress Dashboard.
- Go to Contact → Contact Forms.
- Click on the form you want to edit.
- Open the Additional Settings tab.
- Add the following line:
on_sent_ok: "location.replace('https://yourwebsite.com/thank-you/');"
- Replace
https://yourwebsite.com/thank-you/
with the actual URL of your thank you page. - 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:
- Open your WordPress Dashboard.
- Navigate to Appearance → Theme File Editor.
- Locate and open the
footer.php
file or add the script in a custom JavaScript file. - 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);
});
- Replace
https://yourwebsite.com/thank-you/
with your thank you page URL. - 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:
- Install and activate the Redirection for Contact Form 7 plugin.
- Go to Contact → Redirect Settings.
- Choose the form you want to modify.
- Enable redirection and enter the URL of your thank you page.
- 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!