The Data Science of Digital Marketing

Spinnakr is a new kind of
analytics that takes action for you.

We target your website’s visitors automatically, tripling your sign-ups and sales.

Join our free beta!

How To Track Goals and Conversions in Google Analytics (Using Forms)

Alex is co-founder of Stunt & Gimmick’s, a data-driven full service creative content  firm that “combines elegant prose with beautiful imagery and startling rich content,  tied together with a ribbon of hard data.”

Are you monitoring your conversions? Tracking funnels? Ranking and qualifying lead sources? You should be. If you aren’t, you’re missing out on valuable intel. What should you track? Well, since Stunt & Gimmick’s (and Spinnakr) specialize in web marketing, I won’t bore you with details of in-person tracking. Instead, I’ll jump right into the online side of things, starting with forms.

If you have a lead generation form on your website, you need to be tracking it automatically. Not only do you need to be tracking the form, but you also need to be tracking the individual fields on the form as steps in a funnel, to see if your web forms need help. Hint: they probably do. Google Analytics provides a very easy-to-use tracking mechanism, in the form of “goals.” Goals can be tracked as either virtual pageviews or events. Which one you pick depends largely on your application, but I’m a big fan of virtual pageviews for form tracking simply because GA still doesn’t allow the use of events in a multi-step funnel. The code for setting up a virtual pageview goal in GA is simple enough:

[javascript]_gaq.push(['_trackPageview', 'virtual/page/url.html']);[/javascript]

Lets go through that real quick:

_gaq.push - tells the Google asynchronous snippet to push an event onto their que. Don’t worry if you don’t know what that means. Just think of it as a diner waitress yelling an order back to the fry cook.

_trackPageview - is the GA function that performs the heavy lifting of recording a virtual pageview. Using this function lets you assign “virtual” pages to events that aren’t actually separate pages, like actions inside a Flash movie or JavaScript events.

virtual/page/url.html - is the made-up url you want to track. Make it descriptive, and break it up with backslashes for easy reference. For example if you’re tracking the name field in web form that pops out in a new window on your product page, call it popout/product/name.html.

Easy, right? So now where do you put it? The simplest solution is to add a little snippet in the individual <input> tag that calls the function when the field loses focus like this:

[javascript]onblur: JavaScript: _gaq.push(['_trackPageview', 'popout/product/field.html']);[/javascript]

My biggest problem with this method is that it’s restrictive and can be difficult to implement in certain situations. I once had a client running a WordPress page with dynamically generated AJAX forms that refused to work. My ideal solution is to use jQuery to pick up form movement. It gives you the flexibility to have multiple things happening at once and doesn’t require actually touching the form code itself. This is a big advantage in that it lets you track plug-in and third-party forms that you might not otherwise have code access to. The code, which you can insert anywhere on your page you want, is:


I won’t try to explain all the jQuery elements here, since it would take forever, but has excellent documentation. Substitute the id of your input field in place of #id, and make sure you have a separate copy of the $(‘#id’).blur for each field you’re tracking.

ProTip: make sure you change the virtual pageview URL for each instance. Also, make sure you have a final step bound to the click event of the form submission button. Just substitute “.click” in place of the “.blur.”

Once your fields are being tracked, you’re ready to start seeing results come in. But before you get too excited, you’ll need to set up your Goals from within Analytics for them to work.

Log in to GA and hit that bright orange shiny “Admin” button on the right-hand side.

Make sure you have the right profile selected, and click on the “Goals” tab.

Assuming you haven’t set up any other goals, go ahead and click “+Goal” under “Goals (set 1)”

In the screen that opens up, give your goal a descriptive name, select “URL Destination,” and click “Save”

That takes you to an even MORE fun screen where we get to the nuts and bolts of setting up the funnel.

For the goal URL, enter the final dummy URL you set above (e.g popout/product/field.html), leave match type as exact, and for Goal Value, enter how much the goal is worth. That’s something you SHOULD know, but if you don’t, the most basic formula is (Customer Lifetime Value x Final Conversion Rate, as decimal). Finally, at the bottom, you want to check the “Use Funnel” box and in the boxes that pop up below, enter a step name and the dummy url for that step until all of the steps are covered.

Whew! That was intense, right? Well, the unfortunate news is that that was the easy part. Now you have to actually do something with this data. What you do with it is up to you. I have some ideas, and I’m sure Adam does as well, and it’s possible one of us might be writing a follow-up blog about that. The important thing, though, is that you now have tracking not only for final conversions, but also for every step in your form. This is crucial to understanding where you lose people and why your website is underperforming on conversions.

Good luck, and to borrow from the GA team, happy analyzing!

Spinnakr is a service that helps you target your
website's visitors to increase conversions.

Our Google+ page