Setting up a thank-you page seems simple—until failed submissions start firing false conversion events and users get redirected before fixing a typo.

If you are configuring a redirection for Contact Form 7 WordPress plugin, there is one rule that saves endless tracking headaches: only redirect after the server confirms the email actually sent.

Why Most Contact Form 7 Redirects Fail Silently

Years ago, site owners pasted on_sent_ok into Contact Form 7’s Additional Settings tab. Contact Form 7 removed that setting for security reasons—yet plenty of outdated tutorials still recommend workarounds that fire on every form click.

Here is what actually happens when a visitor clicks Submit in Contact Form 7:

  1. The plugin fires an Ajax request and checks required fields (firing wpcf7invalid if something is missing).
  2. Spam integrations like Akismet or reCAPTCHA inspect the payload (firing wpcf7spam if flagged).
  3. WordPress attempts to send the email via wp_mail() (firing wpcf7mailfailed if SMTP fails, or wpcf7mailsent if it succeeds).

Notice the catch? Even wpcf7submit fires when a submission fails mail delivery. If your redirect triggers too early, visitors never see the red error notice—and your analytics counts a lost lead as a conversion.

Direct DOM Event vs. a Redirection for Contact Form 7 WordPress Plugin

Before installing another plugin, look at what your site actually needs. You have two clean ways to redirect Contact Form 7 submissions reliably.

ApproachBest ForTrade-offs to Check
Native wpcf7mailsent DOM eventSingle thank-you URLs, fast pages, minimal plugin overheadRequires placing a small snippet in a child theme or code-snippets plugin
Dedicated CF7 redirection pluginConditional redirects, passing form fields in URLs, non-technical editorsAdds another plugin to test during WordPress core and CF7 updates
Form plugin with built-in redirectsTeams needing entry storage, multi-step logic, and native confirmationsRequires migrating existing forms (review how to choose a reliable WordPress contact form)

Method 1: Redirect Contact Form 7 Without Extra Plugins (Recommended for Simple Flows)

If you only need to send users to a thank-you page after submission, Contact Form 7 already exposes the hook you need. As outlined in the official Contact Form 7 DOM events documentation, the wpcf7mailsent event fires exclusively when mail is accepted without errors.

Before adding custom scripts, take a quick restore point using our WordPress backup and recovery guide. Then load the snippet below in your footer or via a lightweight snippets manager:

<script>
document.addEventListener('wpcf7mailsent', function (event) {
  if (event.detail.contactFormId === 123) {
    window.location.assign('https://yourdomain.com/thank-you/');
  }
}, false);
</script>

Why the form ID check matters: Replace 123 with your actual Contact Form 7 ID. Otherwise, every form on your site—including newsletter signups or footer enquiries—will redirect to the same URL.

Method 2: When to Use a Redirection for Contact Form 7 WordPress Plugin

Code isn’t always the best workflow for growing marketing teams. If editors regularly launch landing pages and need point-and-click control inside the WordPress dashboard, a maintained redirection for Contact Form 7 WordPress plugin earns its keep.

Look for an add-on that checks three boxes before activating it on production:

  • Success-event binding: Confirm it triggers on wpcf7mailsent rather than hijacking the form’s submit button.
  • Per-form & conditional rules: You should be able to route “Sales” inquiries to one URL and “Support” requests to another based on a dropdown field.
  • Strict role permissions: Only trusted administrators or editors should modify redirect URLs so external links aren’t altered unexpectedly. See our WordPress user roles and capabilities guide to lock down editing access.
Three-step checklist: Define the real success condition; Use the supported event or maintained extension; Review destination and measurement behavior
A three-step checklist for configuring and verifying a Contact Form 7 redirect without losing lead data.

Don’t Break GA4 Tracking When You Redirect

Here is a subtle trap that catches even experienced marketers: redirecting immediately inside wpcf7mailsent can cancel outbound Google Analytics 4 or Meta Pixel requests before the browser finishes sending them.

Two easy fixes prevent missing conversions:

  • Track the destination page instead: Fire your generate_lead conversion on the /thank-you/ page load (with noindex enabled so organic searchers don’t land on it directly).
  • Or delay navigation slightly if firing an event on submit: If you push a dataLayer event inside wpcf7mailsent, wait 250–300 ms or trigger the redirect inside your tag’s eventCallback so the hit completes before page unload.

How to Test Your Contact Form 7 Redirect in 3 Minutes

Never stop at one happy-path test. Run these four quick checks in an incognito window before calling the setup done:

Test ScenarioWhat Should Happen
Submit with a missing required fieldStays on the form page and displays inline validation errors—no redirect.
Trigger an invalid SMTP or mail failureDisplays the orange/red mail error box; visitor is not sent to the thank-you page.
Submit a valid test entryEmail arrives in the target inbox, then the browser redirects cleanly to the thank-you URL.
Reload the thank-you pageConfirm your analytics setup does not double-count conversions on page refresh.

Frequently Asked Questions

What is the safest way to set up redirection for Contact Form 7?

Use the wpcf7mailsent DOM event—either via a short JavaScript listener scoped to your form ID or through a maintained Contact Form 7 redirection plugin that binds to that same success event. Avoid binding redirects to the submit button click.

Why did on_sent_ok stop working in Contact Form 7?

Contact Form 7 deprecated and removed on_sent_ok because storing executable JavaScript inside form settings created security risks. Modern setups must use DOM event listeners or dedicated add-ons.

Should I block my Contact Form 7 thank-you page from Google?

Yes. Add a noindex directive to your thank-you page so visitors don’t find it via search results and inflate your conversion counts without ever submitting a form.