Tips & Tricks

Contact Form 7: Redirect After Form Submission

Contact form 7 Redirect after submission

Trick in this post may or may not be that much useful to developers, but for SEO guys I am sure this is going to be very useful.

Well, Contact form 7 is the most used contact form plugin of best blogging platform which is WordPress.

Contact form 7 Redirect after submission

This plugin uses the AJAX to submit the form for better user experience of course. Submitting the form via AJAX is one of the major problem for SEO guys as normally they will have lead conversion in their action plan. For that they would need one contact page(where the form resides) and one thanks page(where the success message resides). With the use of these two pages they configure Google Analytics to calculate the lead conversion.

Problem

As contact form 7 is using AJAX to submit the form, there won’t be any success page, which create a problem for the SEO guys.

Solution

Just like wordpress, this plugin comes with various hooks for the form submission. We are going to use one of that hook which triggers after the form submission is completed. The hook name for this functionality is [code]on_sent_ok[/code].

While creating a new form with Contact form 7 you will have Additional setting box at the end of the page. In that box you need to mention above hook name with the page where you want to gets redirected after form submission. You need to mention this hook in below pattern:

[cc lang=”php”]
on_sent_ok: “location = ‘http://domain.com/thanks’;”
[/cc]

Of Course, You need to change the URL value to what you have for your site. After placing the above code in additional setting box, your box would look like below image.

Contact form 7 redirect Hook

After this save your form and check how it works. Now it will be easy for you to set up conversion tracking in Google Analytics.

Share your views/comments/suggestion to improve this article or may be another super easy method to achieve this.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *