Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Monday, July 8, 2013

Contact Form 7: Redirect After Form 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.
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 on_sent_ok.
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:

on_sent_ok: "location = 'http://domain.com/thanks';"
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 .
Addition Settings
on_sent_ok: "location='http://domain.com/thanks';"

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.

No comments:

Post a Comment