Customize The WordPress Contact Form 7 Plugin

I ran into an interesting problem the other day.    I’m a big fan of the WordPress Plugin Contact Form 7.  I’ve used it on many of the wordpress sites I’ve developed, and appreciate the plugin for its simple integration, nice admin interface, and the pretty ajax functionality.

Unfortunately, I recently discovered that the plugin does not allow you to specify custom landing page urls, or Thank You pages for the contact form.  Some of you may wonder why I care about reloading the page to say thank you vs. the sleak Ajax popup confirming that your message has been delivered.  The answer: Because I’m trying to measure performance of the contact form within my Google Adwords CPC account.

You can use javascript to fire the tracking code to create a virtual page view in analytics, but you cannot properly implement the conversion tracking from Adwords without loading a separate page.    As you can imagine, I was slightly frustrated until I discovered a very quick and simple solution.

Important.. This solution only works if you have/want a designated landing page for all forms you are using with Contact Form 7.

Step 1: Browse to wp-content/plugins/contact-form-7

Step 2: Open the contact-form-7.js file in your favorite text editor.

Step 3: Look for the function:  wpcf7ProcessJson (line 63)

Step 4: Look for the if statement: if (1 == data.mailSent)  (line 90)

Step 5: Insert this line after the jquery (line 92) – location.href=””;

Step 6: Save the file to your server, and test out the form.
Ideally, the author of this plugin will make a change in the next release that allows a custom variable (url) to be stored for each contact form.  But until then.. here’s your fix !!!

For .p7m files go to:
For .kml files go to:
For .3g2 files go to:
For .itl files go to:
For .bup files go to:
For .svg files go to:
For .part files go to:
For .pdf files go to:
For .jnlp files go to:
For .ithmb files go to:

8 thoughts on “Customize The WordPress Contact Form 7 Plugin”

  1. Thanks for putting that online, you’re a star.
    The version I used was slightly different, maybe i have an older/newer version.

    it was after line 44 in scripts.js:
    if (1 == data.mailSent) {


  2. Thanks. Looks like a great solution. Do you know how to populate the data submitted by the user onto the Thank You page so they can see a summary of it? I’d also like to have my own text as well as a PayPal button on the Thank You page, but since I would be creating the page, that’s a no brainer. I just need to know how to create a summary of the data on the Thank You page. Thanks!

  3. Hi ,

    I tried this but its not working for me, I deactivated all plugins with only contact form 7 plugin activated but even though it was not working , I also check the footer.php file for wp_footer(), and it is there . Please do me a favor in this regard. I am using wordpress version 3.1.3 and contact form 7 version 2.4.5 which is I am sure is compatible with upto wordpress’s 3.1.3 version.
    Please help me out what else I have to do.


    1. Hi Dinehs, what is the URL of the site for which you are having issues? I don’t support this plugin… just posting a tweak I made for myself, but I don’t mind taking a look in case you are missing something basic.

  4. Here’s an easier way … just use the “additional settings” field you can find in the admin settings underneath each and every form … and just put the line in there:

    on_sent_ok:”location = ‘’ ;”

    All done. And no risk of loosing the configuration come the next update.

Comments are closed.