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=”http://www.yourdomain.com/yourthankyoupage”;
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 .kml files go to: http://www.fileextensionkml.net.
For .3g2 files go to: http://www.fileextension3g2.net.
For .itl files go to: http://www.fileextensionitl.org.
For .bup files go to: http://www.ifileextensionbup.com.
For .svg files go to: http://www.fileextensionsvg.net.
For .part files go to: http://www.fileextensionpart.net.
For .pdf files go to: http://www.ifileextensionpdf.com.
For .jnlp files go to: http://www.fileextensionjnlp.net.
For .ithmb files go to: http://www.fileextensionithmb.com.
thanks for info can you tell me how to disply the radio button vertically by contact form7 setting code
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) {
$(data.into).find(‘form’).resetForm().clearForm();
ro.addClass(‘wpcf7-mail-sent-ok’);
Thanks!
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!
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.
Thanks
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.
[…] Custom Landing Page for Contact Form 7 | Jacob Bohall […]
thanks, I was just looking for such a solution, you helped me alot
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 = ‘http://www.example.com/landinpage.htm’ ;”
All done. And no risk of loosing the configuration come the next update.