How to Capture Form Data With Google Analytics Event Tracking

You don't have to wonder how site visitors use forms on your Web pages when you track form data using Google Analytics event tracking. This free service. which also monitors Web traffic, can help you track any form on your website and view detailed reports that show the form's activity. Because Google's servers contain the software needed to track this data, you only need to add a few lines of code to your HTML document.

Instructions

    • 1

      Navigate to the Google Analytics website and sign up for a free account if you do not have one. Follow the instructions as the site walks you through the signup steps. When you complete the process, the site displays a small block of JavaScript code in a text box.

    • 2

      Copy the JavaScript code and paste it into your HTML document before the closing body tag.

    • 3

      Add the following code to your document's body section:

      <form>
      Name <input type="text" name="customerName" /><br />
      </form>

      This creates a simple form that contains text box.

    • 4

      Paste the code shown below before the form's closing "</form>" tag:

      <input id="buttonHelp" type="button" value="View Help"
      onclick="_gaq.push(['_trackEvent', 'Form', 'Help', 'Get product help']);" />

      This code adds a "View Help" button to the form. The button's onclick event passes a category, an action and a label to Google Analytics. "Form" is the category in this example. The action is "Help" and "Get product help" is the label.

    • 5

      Change those three values to anything you like. Categories help you group page elements you wish to track. In this example, "Form" will appear on your analytics report as a category when someone clicks the "View Help. "Help," the action value, helps you identify the action that the element performs. The label parameter allows you to provide further descriptive information that may assist you when you view your analytics report.

Tips & Warnings

  • Capture any form data you like using the technique described in the onclick example. For instance, you might add an onchange event to an input text box that passes other descriptive values for category, action and label to Google.

Related Searches:

References

Resources

Comments

Related Ads

Featured