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.
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.
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:
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.
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.
Avinash Zala currently working at a leading web development company as a Sr. PHP Web Developer. He is the founder of the Xpert Developer. He has completed B.E. in Information Technology. Born and brought up in Ahmedabad. He loves to code and coding is all about passion for him. Follow him on twitter at Avinash Zala & Xpert Developer.
View all posts by: Avinash