Tracking Goals for Your Web Application with Google Analytics
I can not stress enough how important I consider tracking. The more you can track the better.
This is especially true when it comes to how much your users are sharing elements of the site with their friends, inviting new potential users and, of course at what percentage they convert to paying customers. That is what we will be covering here.
There are a few popular monetization models used by web applications. For the purposes of this article we will concentrate on the “freemium” model. That is, offer users some limited account type for free with the option of upgrading to a paid version with more features.
The key here is that we want to know what we are tracking and that’s easy with a freemium model:
- Conversions from Visitor to Free User
- Conversions from Free User to Paid User
Of course, you should be tracking much more than just that. In fact, you will be tracking as much as you possibly can but that is outside the scope of this article. Account profile updates, sharing (very important), upgrades to more plans if you offer several tiers, and downgrade are all things that are pretty important in establishing a real outlook for your application and business.
In freemium models, we want to deliver the user to the action they would like to take as quickly as possible. So if there is a sign up process standing between the user and uploading a photo, we want them to sign up real quick and then be dropped on that photo upload screen immediately. That means we’re usually getting rid of the superfluous “thank you” pages that we used to see everywhere and instead using flash messages to notify a user that their action was successful.
One benefit to flash messages is that it creates a built-in infrastructure of excellent event tracking.
A Case Study as a Tutorial
I wanted to track anonymous-to-free and free-to-paid conversions on Folioly, a model portfolio site. However, because users are immediately dumped into their dashboard once they sign up, the address the user lands on after making those conversions is the same URL that users are hitting all day. Therefore, if we don’t want to have a bunch of garbage data in our analytics, we need to track a custom pageview when the user sees a “success” flash message.
In Your App
First I put the default tracking code in. This is the asynchronous version which has a number of benefits which I won’t go into here. It’s important to note though, because the _trackPageview options we’re going to embed later are different from the standard Google Analytics code snippet you get when you create a new account.
Like most people, I put my tracking code in a partial. In this case, _ga.html.haml. That file is shown below with the addition of my new if flash.
Note that we use HAML in our Rails projects so you’ll have to do some editing if you’re a copy & paster.
%script{:type => "text/javascript", :charset => "utf-8"}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-XX']);
_gaq.push(['_setDomainName', '.folioly.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
- if flash[:analytics]
%script{:type => "text/javascript", :charset => "utf-8"}
= flash[:analytics]
As you can see, we’re throwing in another script if our new flash gets called.
For example, when a user creates an account and sees the flash message “Account successfully created” we also want to insert a new _trackPageview for “/free” (so we can track that as a goal). One caveat is that this will generate two pageviews when the convert happens. I feel that this is negligible considering the overwhelming value this data generates.
Below is what our Free-to-Pro flash message looks like with the [:analytics] code in there.
if sub = user.subscriptions.create() flash[:notice] = "Account successfully upgraded." flash[:analytics] = "_gaq.push(['_trackPageview', '/pro']);" else flash[:error] = errors_for_flash(sub) end else flash[:error] = "You've just made a terrible mistake." end
These two flash messages—”Account successfully created” and “Account successfully upgraded”—are now not only helpful feedback for our users but also extremely helpful to you for goal tracking.
In Google Analytics
We have some new tracking to work with in the form of pageviews to our site. Here’s how it breaks down when you’re looking at our Google Analytics for Folioly:
- Conversions from Visitor to Free User register as pageviews to folioly.com/free
- Conversions from Free User to Paid User register as pagesviews to folioly.com/pro
Now that our data is recorded we can add some goals. We need two goals—one for each of our conversions.

Let’s check out our first goal, Free Conversion.
Note that we track subdomains on Folioly with an Analytics filter (not covered in this article) so that’s why you see /folioly.com in the boxes below. However, for your site you will likely just use /free and /pro.

Just to reiterate what is in the screenshot, we have an Exact Match goal type with the web address /folioly.com/free which is what our Visitor-to-Free flash message pageview is.
In the funnel, we have /folioly.com/register/ set as a required step since in order to sign up for an account on Folioly one must visit the registration form and put in their information. If your sign up process has more steps I would encourage you to put those steps in your funnel so that you’re able to visualize the funnel later.
Utilizing the Data
This is extremely helpful in stamping out problem areas in your sign up or conversion process that might be discouraging users from pulling the trigger.
With this data we can now visualize how our users are converting (hopefully) or not converting on the site. More importantly, if you’re tracking which paid advertising campaign that user came from, you can immediately see what the conversion rate for that particular ad spend is.
If you’re not doing this, you should not be spending money on CPC advertising (or much of any online advertising, really) because you’re basically throwing money into a black hole.
You want to track how valuable that paid traffic is, how long it takes them to convert, how they eventually end up converting, and more.
Tags: conversions, freemium, funnels, goals, google analytics, tracking
The trouble I find with all this traffic information is what to do with it all! You are given every statistic about your visitors that you can think of! So thanks for helping me try and focus on what’s most important.
Thanks for sharing the inro with us, I have been trying to work out how to and what to do with it for weeks, been driving me mad lol – I will sit down now and try and get it all sorted.
Cheers DJ