OnSubmit & OnClick Goal Tracking in Google Analytics

By Amanda Sides | Jan 16, 2013
More Articles by Amanda

If you know me at all, or Marketing Mojo, or anyone in the search industry for that matter, we are all big advocates of using Google Analytics to track activity on your site. Having the insight into where your traffic is coming from and what visitors do once they arrive on your site is very valuable to your bottom line, whether you realize it or not.

Goal-setting is important for any aspect of your life, but in this particular instance, for your online efforts. Establish goals in Google Analytics to track conversions that you’ve set as high priority, or even if you’re just curious how many you are getting. The main goal types used are a URL Destination setting, tracking a goal when that specific URL is triggered. You can also set goals for things like if a visitor travels to a certain amount of pages per visit, or stays on the site for a certain length of time.

One conversion type that is under-utilized and could give site owners a lot more insight into mini-goals, or goals that can’t be tracked via the URL Destination type.

Setting Up the “Event” Goal Type

As a quick refresher, to find the goal set-up page, simply log in to your Analytics account, navigate to the profile where you’d like the goal to live, then find the Admin link in the top right.  For this goal, you’ll want to select Active, Event, and then fill out the Goal Details as appropriate. I tend to only use Category, Action, and Label, and choose the “that matches”option.

google analytics event tracking

When to Use “Event” Goal Tracking

Good examples of actions that could be tracked with event goal tracking are PDF downloads, form submissions that don’t have the confirmation page on a new URL, or forms that direct to a third party site, where your Analytics tracking will most likely end.

OnSubmit Event Tracking

You’ll want to use onsubmit code to track form submissions (in the event that you are unable to track with a more traditional method). The code would be placed at the opening of the form code, not on the submit button. Here’s an example of the onsubmit code within the beginning form code:

<form id=”pledge-form-home” action=”take_pledge_handle” method=”post” onsubmit=”_gaq.push([‘_trackEvent’, ‘Sample Category’, ‘ Pledge’, ‘Sample Label’]);” >

OnClick Event Tracking

You’ll want to use onclick code to track a click on a specific button or link. For instance, we have a client right now where we track the form submission for a program guide download, and also track the physical click on the download button on the thank you page to see how many leads end up actually downloading. Here’s an example of what your onclick code would look like:

<a href=”files/ProgramGuide.pdf” onclick=”_gaq.push([‘_trackEvent’, ‘Sample Category’, ‘Download’, ‘Program Guide’], [‘_trackEvent’, ‘Program Guide’, ‘Website’]);”><span>Download</span> the program guide</a>

For more information on how to set up goals in Analytics, visit the Analytics Support Center, and for more advanced events tracking information, check out Adam’s post on “Getting Your Conversion Data Right with Advanced Solutions for Google Analytics Event Tracking.”

Share this article

Facebook Icon Twitter Icon LinkedIn Icon Google Plus Icon Pinterest Icon

Subscribe today!

Join over 4,000 marketers who receive actionable digital marketing insights.


Blog Search

  • Very nicely explained article. I follow the steps and generate event goals for my site but now I want to know how do I ensure that they goals are working fine.

    • Adam Smith

      You can do a couple of things. The easiest is just wait and see if goals start generating in Analytics. If they don’t, you either have a problem with the code or nobody is performing the action that fires the event.

      To find out quicker, I use the GA Debugger plugin for Chrome. It’s spits out all the interactions between your page and Google Analytics to the JavaScript console. Super handy!

  • I have a somewhat complex (for me) onsubmit requirement that I would rather sub out to an expert (and learn from that) than learning from trial and possible error on the client’s server. Are you amenable to smaller jobs like that? If so, happy to open an email dialogue where I can share the particulars. Thanks! -R