« Advanced Google Analytics: Conversion Goals (Part Two) | Main | »
Advanced Google Analytics: Conversion Goals (Part Three)
May 29, 2008 in Analytics, Expert AdviceIn part one of this series I covered the basics of setting up goals in GA (Google Analytics).
In part two I covered setting up funnels.
These are both straightforward techniques that everyone should be using because you can do them without ever touching your website (assuming you have the GA code installed on your site, of course).
Today, I'm going to cover a more technically advanced topic. Namely, tracking things that don't have a distinct page view associated with them. This one will require some web page editing know-how, and a little bit of programming savvy, but not a ton if you carefully follow along.
Tracking goals with no distinct associated pageview
Remember that goals are really just a pageview that you've specified as being a goal inside GA. To track a goal without a distinct pageview associated, we're going to simulate a pageview using simple javascript.
First, let's define what we mean.
Here are a couple examples:
Let's say you've got a software download you offer, but visitors just click a download link to get the software. There is no specific pageview, just a link someone clicks to download a file.
Or, you have a registration form that when filled out - doesn't go
to a specific unique page you can enter into GA. Maybe it goes to their
new profile page, but that's not a page that only constitutes
the completion of a goal because this same user (and others) will
return to that same page many times in the future.
Here's how we handle that:
It's simple and brilliant really, you just use a snippet of javascript code (provided by Google) which simulates a pageview.
When the action you desire has taken place (say, they clicked the download software link, or they filled out the form), you use the little javascript call to simulate a pageview.
Let's walk through an example:
First, set up your goal as before. This time pick Exact Match, and
for your Goal URL, you can make it anything you'd like. Start with the
slash, (/) and then use a fairly descriptive name, no spaces. It can be
anything you want. This is the pageview we'll be simulating in a moment. For the Goal name, this is how it'll appear in the report, so put something meaningful. (Only you will see it.)

Define a funnel if you wish, these would be the pages leading up to the goal. Perhaps you have a product screenshot tour, followed by the download link. Put the steps to the tour in the funnel.
Now comes the technical part.
Move the original GA code to the top of the page
First - On the page where the goal happens (from our example above, the page where the software download link is) you're going to need to move the original GA code to the top of the page instead of the bottom (which is where they initially tell you to put it). The safest place to put it is right after the first <body> tag. It must appear before the new snippet we'll be using below to simulate the pageview. If needed, you can do this for every page, not just the ones where the goal happens.
Make the pageview simulation javascript call
Don't get freaked out! This sounds complicated, but it's simple. All you need to do is have the following javascript where your desired action takes place.
pageTracker._trackPageview('/GOALPAGEHERE')
So, for our example above, on the software download link, I'd do the following:
<a href="MySoftware.zip" onclick="pageTracker._trackPageview('/DownloadSoftware')"> Download Software!</a>
The part in red, is the part I added. the "onclick=..." mumbo jumbo says, when someone clicks this link, make this javascript call which simulates a pageview. Note the value I have in the parenthesis and single quotes matches the value I put as the Goal URL above. These values must match.
Ok let's do another one with our second example, someone is filling out a signup form.
Here's how we'd define our goal inside GA.
You have two options with simulating the pageview. You can either trigger it when the form is submitted this way:
Option 1:
Put the part in red in the form tag on your signup form.
<form action="..." method="..." onsubmit="pageTracker._trackPageview('/NewSignUp)">
Option 2:
Or, you can use your backend code to show the following on the profile page, only after a signup happens. I'd put this at the bottom of the page just before the </body> tag:
<script type="text/javascript">
pageTracker._trackPageview('/NewSignUp');
</script>
And that's it!
This tip requires a bit more technical savvy, but if you have a scenario where you need to track a goal without a distinct pageview associated, it's the best way.
Hope this helps.
In our next, and final installment, we'll discuss how to track track the income from certain goals (goal value tracking).
Comments
This series has been great! My analytics will never be the same. I have changed my use of analytics completely.
Thanks.
Posted by: Mike Michalowicz | Jun 3, 2008 2:16:21 PM
Thanks for the feedback Mike, I'm glad you've found it useful.
Posted by: Carson | Jun 3, 2008 2:21:45 PM
Great tutorial Carson, you really made it easy to understand - and I only have about 6 months of self taught html behind me.
Can't wait to see some figures on what was previously "hidden"!
Posted by: Jon Weston | Sep 19, 2008 11:30:55 PM
I found a way to track adsense clicks on my website.
(1)In match type Choose Head Match,
(2)In Goal URL type http://pagead2.googlesyndication.com/
(3) Name it "Adesnse Clicks"
(4) Uncheck Case sensitive, if it is checked.
I have tried it on my website and it works.
Posted by: Mehul Vansdadiya | Sep 25, 2008 3:28:22 AM
great ive been looking for this thanks
Posted by: el | Nov 9, 2008 9:51:05 PM


