I’ve used Contact Form 7 for years and it’s a great plugin, but I’ve recently had a problem with redirecting to a thankyou page after submission of the form. I was using Contact Form 7 version 4.2.2. Scroll to the end to read the solution.

Contact Forms 7 documentation says to add this to the ‘additional settings’ section of the form:

on_sent_ok: "location = 'http://example.com/';"

For some reason, this had no effect at all. Some people seemed to suggest that a recent update stopped that part working. It’s certainly worked for me in the past so I was surprised to see little mention of it in the support forums or documentation.

When I was looking for a solution, other users suggested adding this code to the ‘senders message was sent successfully’ field:


This didn’t work for me either. I was getting pretty frustrated with the amount of time I was wasting on what should have been a very quick thing to do. I would have loved to have switched to Gravity forms which is much more robust and has many more features than Contact Form 7 but that wasn’t an option on this project. Luckily though, I found a plugin that not only claimed to add redirect functionality to Contact Form 7 but also some other useful stuff to. The plugin is called Contact Form 7 Controls.

The Solution

Download and activate Contact Form 7 Controls. You’ll then get a handy ‘Customize’ tab on each contact form. Not only can you specify a redirect URL which actually works but you can trigger Google Analytics events for each form submission too. Really handy!