Narasopa Media
home | blog | contact

Adding Redirects to Contact Form 7

As you probably know by now, I use Wordpress on a lot of different sites – I really think that it is a miraculous piece of software. Recently I’ve been approached by quite a lot of people in the home based business community who are doing Google Adwords advertising on their sites, and need to track conversions.

One of my favorite Wordpress plugins is Contact Form 7 – it is a powerful and extremely simple contact form that can be set up in a matter of seconds. Until recently, though, there was no good way to get it to use a custom thank you page – you had to go into the code and hack about, and they were releasing updates on a frequent enough basis that by the time you had your hack in place they were already asking you to upgrade the software.

Anyhow, this has now been fixed and the solution is ever so easy.

At the bottom of the settings page for Contact Form 7 is something called “Additional Settings”

Simply paste the code below into that box, edit the thank you page to reflect the URL that you want, and you are off!

on_sent_ok: "location.replace('http://www.mysite.com/mypage.html');"

Then simply paste the conversion code into your thank you page and you are ready to track contacts / signups on your site!

Note:
I found this solution on the comments at http://www.grapethinking.com/wordpress-contact-form-7-plugin-landing-pag – I will keep my eyes out for any further updates, just wanted to post this clearly as I had to dig around for hours to find it!!

Share and Enjoy:
  • Facebook
  • Twitter
  • MySpace
  • Digg
  • del.icio.us
  • NewsVine
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Live
  • Google Bookmarks
  • Yahoo! Buzz

10 Responses to “Adding Redirects to Contact Form 7”

  1. Kim writes:

    I was wondering if you could help me. I’m desperate to know why this code doesn’t work on my site:

    on_sent_ok: “location.replace(‘http://www.nightmareon13th.com/coupon.html’);”

    Everything I read says I’m doing it right, are there any common mistakes I could make that would prohibit this code from functioning properly?

  2. Justin Handley writes:

    Hi There Kim.

    My first guess is this – you copied this from a site somewhere online that had opening and closing quotes, and you need to get rid of them. The end quote after .html is a closing quote, and it needs to be a .. I don’t know what you call it – quote that isn’t an opening or closing quote. I am going to type it correctly here and you can try to copy and paste it, but if that doesn’t work try typing it directly into the box in wordpress (no copy and paste) and see if that works. If it doesn’t post back and we’ll see what we can figure out.

    on_sent_ok: "location.replace('http://www.nightmareon13th.com/coupon.html');"

    Try it and let me know how it goes.

    Justin

  3. Kim writes:

    Hi Justin, I see what you mean. But it still isn’t working even when I fix the quotes. I’m running the latest version 2.0.1, what version are you running? Thanks so much for your help
    Kim

  4. Justin Handley writes:

    Have you made any changes to the plugin already in your attempt to make the redirect work? Are you using the automatic plugin installer in wordpress? I would recommend deleting the plugin, downloading the plugin from it’s page, uploading it via ftp, reactivating it, and then trying again. Before you do that, though, maybe try to make sure there aren’t any spaces before or after your code – go after the last ” and hit delete a couple of times…

    Let me know if this works!

    Justin

  5. Squarecandy writes:

    Thanks for the concise post – works like a charm (with the straight quotes). Curious if anyone found documentation for the most frequent/common/coolest mods you can do with that “additional settings” field – seems like it really opens up that plugin for easy modification that will withstand future updates.

    Also – works for me with a relative link:

    on_sent_ok: “location.replace(‘thank-you’);”

  6. Michael Mason writes:

    Changing the quotes fixed the issue for me! Now, my quote request page is forwarding to the appropriate “Thank-You” page.

    Is there any way to get rid of the green success message that appears right before the page re-directs to the “thank-you” page?

    Also, it seems like it takes a LONG TIME for the form to submit. Is there any way to make it go quicker?

    Thanks!

    Michael

  7. Justin Handley writes:

    Making it go quicker – that is something I’ll leave up to the plugin developer. As for getting rid of the green message, try this:

    Remove line 69 of includes/classes.php

    $content = $_POST['_wpcf7_mail_sent']['message'];

    I did that on my contact form (link at top of page) and it seems to be working…

  8. Ramon writes:

    Hi there.

    I think I tried everything but I still don’t manage to get this working!.

    I tried the ‘hacks’ that someone coded before this Additional Settings feature came up and it didn’t work for me. Then I saw this new feature and I thought it would finally work but it didn’t.

    I checked the quotes and the spelling and it is perfect, and I also reinstalled the plugin to make sure that everything was correct and there was no previous modification.

    Any help would be much appreciated.

    Thanks!

  9. Justin Handley writes:

    My only thought here is..

    1. Make sure you have the latest version of wordpress.
    2. FTP in and manually delete the folder where the plugin was living. The thing about upgrading is that it doesn’t replace all files – and I did the same thing. The fact that you’ve already messed with it is a bad sign for getting it to work – so go in and delete it by hand.
    3. Reinstall it by downloading it and uploading it yourself.
    4. Activate and try again
    5. Clear you cache

    Those are my thoughts – I think you are retaining an old file that you’ve hacked which is messing with the ability to use the new features, either in your cache or by not deleting everything and uploading it from scratch…

    Other than that I’d have to have login and play with it – if you want me to try you can fill out the contact form on this site and I’ll take a look.

  10. Ramon writes:

    Hi Justin,

    Thanks for your response.

    However, I started working with a different plugin (CForms II) that is also really good and I managed to get it working as I wanted to, so I don’t need anymore Contact Form 7.

    Thanks anyway!

Leave a Reply