How to Setup a Goal in Google Analytics to Track Web Form

Setting up a Goal with Google Analytics to Track Web Form Submissions

A previous post from last week I wrote about “How to Setup a Goal in Google Analytics with a Virtual Pageview.” This week I will be showing you how to setup a goal with Google Analytics to track your web form submissions. This is probably the most popular reason to use a goal in Google Analytics.

In this example I will be using WordPress and the Contact Form 7 plugin. The same steps pretty much apply if you aren’t using WordPress and Contact Form 7.

Step 1

First in WordPress, if you haven’t already, create a “Thank You” page for your contact form to post to.

Step 2

Now we will go into Contact Form 7 and into your contact form. In WordPress, go down to the “Contact” section and click on “edit” on your form.

wordpress contact form 7

Step 3

Scroll down to the bottom and under the “Additional Settings” section add the following piece of code. You are setting up the contact form to post to your thank you page after submission. “thank-you” might vary depending on what you named your thank you page. Then hit save.

on_sent_ok: "location.replace('');"

Advanced Settings Contact Form 7

Step 4

Now we will go over to your Google Analytics account. On the top right-hand side click into “Admin.” Then click into “Goals.”

Google Analytics Create Goal

Step 5

Click on “Create a Goal” and then give it a name. In my example I am naming the goal “Web Form.” Then select “Destination” as the type. And click Next.

Goal Name - Google Analytics

Step 6

In the Destination box put the following: /thank-you/ And click on “Save Goal.”

Google Analytics - Destination

Step 7

To view your Goals, go back to your Analytics account, go down to the “Overview” under Conversion Goals. Whenever someone fills out a form in Contact Form 7 and hits that “thank-you” page, a goal is completed.

Viewing your Goals in Google Analytics

As always feel free to leave your comments below!

author bio
Brian Jackson

I craft actionable content and develop performance-driven WordPress plugins. Connect on Twitter, subscribe to my newsletter (once a month), or buy me coffee.

6 thoughts on “How to Setup a Goal in Google Analytics to Track Web Form”

  1. Hi Brian,

    And If contact form doesn’t send the form? what’s the way to track this? I create a error page like thank-you and set other goal to errors?

    • Hi Jofran? What exactly are you trying to track? You are wanting to track if they try filling out the form and don’t meet all the requirements?

  2. Hi Brian,

    Cool post! In terms of the format for the thank you page what do you recommend? Generally, isn’t a thank you page usually php? Would I just use for example page.php from a theme and turn it into thank-you.php and make it a template? Thoughts?


    • Thanks Michael. If you are running WordPress, yes just create a new page named Thank You, which in turn the URL will become thank-you. If you are outside of WordPress yes, just create a PHP page called thank-you.php and your goal will work fine.

  3. What if you have an Ajax form on a sidebar and redirecting the user would be counter-intuitive? Why aren’t there ANY good articles on a solution for this??? I have been tearing my hair out for a week on this topic!!! ARGGG!!!


Leave a Comment