Google Analytics is more than just page views. As developers, we can use it to measure how our users actually use our apps and use that data to figure out how to make it better. It’s free and best of all, you can do all of this with less than 3 lines of code.
The presentation is about 45 minutes long and the Q&A session ran 15 minutes.
- User flow analysis
- Google Analytics vs Mixpanel
- Discovering user drop off
- Analyzing user engagement with event tracking
- Google Analytics for Developers (PDF slide deck)
- Google Analytics API wrapper for Ruby (GitHub Gist – Mentioned in Q&A)
- Slides + Audio (Vimeo)
This presentation was made at PhillyRB on Jan 15, 2013.
- Gattica : My Ruby wrapper for Google Analytics API
- Uses Google Analytics API v2.
- Basic Authentication. (No OAuth support)
- Simple but kind of old now.
- I’ve moved over to using my “simple” API wrapper for my needs.
- Legato : Ruby wrapper for Google Analytics API by Tony Pitale
- Currently maintained.
- Uses Google Analytics API v3.
- OAuth2 support
- Define a class for creating reports
- Garb : Ruby wrapper for Google Analytics API by Viget Labs
- Not maintained?
- Uses Google Analytics API v3.
- OAuth2 support?
- Google Analytics API documentation
My gist fits my use case. It’s small and reduces my dependencies. But, if you’re looking for my recommendation for your projects, I would personally go with Legato.
Chris: My talk is “Google Analytics for Developers.” I know a lot of people
think of Google Analytics and they think, “Oh, I’m going to track my users
and page views and stuff. This has nothing to do with that.”
I’m going to try and turn that on its head today. I’m going to show you
some really, really interesting things you guys can do with Google
Analytics that will actually help you decide what things you need to do to
better build your application.
Let me just kind of paint a scenario for everybody. Imagine we’re all in
this room. We’re all developers for one company. The CEO walks into this
room and says, “Hey, this form here? It’s too long. It took me five minutes
to fill this whole thing out, man. Listen, we’re losing customers. This
form is too long, blah, blah, blah. Cut it down to three minutes. Make sure
that we can fill this whole thing out in three minutes.” He leaves the
We all look at each other like, “Oh, crap, now what? What do we cut? We
need all this stuff? We need the address. We need pictures, location,
descriptions, we need all this stuff. So what do we do?”
So one guy goes, “No, listen, that Facebook thing? Nobody clicks on
Facebook. That’s like way at the top. We should just get rid of it, just
cut out the code.”
“Well, no, no, we shouldn’t cut out the Facebook, because we have about
1,000 users who are logging in and authenticating using Facebook. If we
take it out what are they going to do?
“Well, I don’t know. Maybe we should get rid of the media gallery.”
“Well, we have, like, 400 users who are using the media gallery. Maybe we
should just move it around.”
So we all go around and around and around. We try to discuss this and we
decide, at some point, to throw everything into GitHub and map out all
these things that we want to do with it. Of course, we just kind of spin
our wheels trying to figure out and understand where we need to go with
One of the things that we can do is collect data on it–a lot of data.
There are a lot of other programs out there and a lot of other services
that can do that stuff, but Google Analytics is one of those things you can
do for free. It’s not only for free, but you can do this with almost three
lines of code, and I mean that. I’ll show you how.
Today, I’m going to go over a couple of topics. The original presentation
had three but I added two, specifically for us. The first one–and I
actually get a lot of questions about this one–is what is the difference
between Google Analytics and Mixpanel? I’m going to actually discuss that
first to get that out of the way and show you quickly what the differences
are. Then I’ll go through the rest of the presentation.
Just a week ago, I found out that Google Analytics had something called
anomaly detection, which is really neat. I haven’t had the chance to play
with it, but it’s kind of cool. So I’m going to go over that.
Google Analytics and Mixpanel. What is the difference between Google
Analytics and Mixpanel? Google Analytics bases everything around URLs.
not so significant, but it’s actually really big. It’s a big difference in
terms of the philosophy and how the actual Analytics work and the work you
have to do to get the data.
Let me just throw a quick example up. You have A, B, and C page. A is on
the root. B is B.html. C is not really a page. It’s actually the video on
the B page. You go to the homepage and there’s a link to B. You got B and
there’s a video on it. Then you have a video playback button that uses
on a bunch of video guys to make a video and we had three people watch it.
Not so cool.”
In order to do this, this is just, basically, what you do. The first top of
it is Google Analytics code. They just give this to you. You literally just
copy and paste this whole thing right at the beginning of the head. I’ll
explain a lot more about this in a bit, but the top part is Google
Analytics and the bottom part is Mixpanel. So, in that respect, they are
If you go to page C, what’s going to happen is, Google Analytics will know
that you went from the root page to page B.html. It’s going to be able to
track the user from page A to page B. It cannot track your play button for
here. It kind of looks like this, minus the comments and things of that
Just on your play button, that’s kind of the thing you’re going to push.
That’s what it looks like. It’s essentially the same thing. One’s an array.
This one’s a hash. No big deal, right?
If you go into Mixpanel, here is the big difference. If you’re going to go
through Mixpanel, every single one of those events that happen in
step one, step two, step three, these are parts of your funnel and they’re
all named, which is great because what that means to us as developers is
that Mixpanel gives us a lot of control over every single point in the
funnel. Every little button we want to play with, every movement of the
mouse, whatever we want to do, we can totally do it.
The problem is we’ve got to do all of it ourselves, everything. We’ve got
to code it all in ourselves, which is fine for us developers, but if you
are a marketing person who literally just basically figured out what HTML5
is, that’s not a great thing, because they’re not going to be able to
figure that out.
So there’s a sort of give and take with it. Google Analytics, you cut and
paste some code and you get a lot of stuff for free. Mixpanel, you have to
do a lot of work yourself.
That just kind of gave you a quick rundown. By the way, throughout the rest
of my presentation, I’m actually going to intersperse some Mixpanel stuff
in here, so you can see the comparison. On the left-hand side, I have
Google Analytics. Basically you get to see where people are going versus
Mixpanel seeing what people are doing. I’ll show you how that has
advantages and disadvantages.
Google Analytics is more integrated, so if you’re doing things like
marketing campaigns with AdWords, if you’re doing keyword research to find
out who is coming to your site, and things of that sort, that’s really,
really good for Google Analytics.
Mixpanel doesn’t have any of that. It’s just measuring the ad itself.
Google Analytics has a ton of data. It’s actually pretty overwhelming.
Mixpanel does not have all that data.
That’s great because Mixpanel’s reports are a lot simpler to deal with. The
Google Analytics reports are pretty complicated. It’s kind of give and take
with data, right?
Segmentation, market segmentation or user segmentation, one uses variables
and regex and the other one uses hashes, again, regex because of the URL.
Google Analytics does not have a built in cohort analysis. Mixpanel does.
One other thing I found out. Mixpanel has a thing where you can put actual
users and their names and addresses and stuff into the system and you can
look at each individual user if you want to. Google Analytics, it’s
actually against the terms of service, you cannot do that. You are not
allowed to put user identifiable information in Google Analytics. They will
kick you out and ban you.
Audience Question: Does that include the database ID or no?
Chris: I’m sorry?
Audience Question: Does that include a database ID?
Chris: If they can’t define it, it’s fine. This is my interpretation,
because that’s not actually said. If you put an ID in there, it’s just a
number. You don’t even have to call it ID. Just ID. They won’t know.
Audience Question: What if you put in a Social Security number, for
Audience Question: They know yours.
Chris: Yeah, exactly. Don’t.
The other thing is that Google Analytics is free and Mixpanel is not. You
actually pay for the number of data points you get. You get 25,000 data
points for free, and then the numbers start at $150 a month after that. So
it’s not free.
This is kind of a cheap version of that, a pretty good solution. Just keep
in mind you’ve got to do a little bit of work on your end. Okay?
To recap real quick, Mixpanel is harder to set up. You get less data, but
it’s really easy to customize and the reports are really simple. Google
Analytics is easy to set up. You literally just copy and paste code. You
get everything for free and lots of data, but customization and reports are
a pain in the ass. Just letting you know.
We’re going to go through some other simple stuff so you guys can see what
it’s all about.
The way I broke this up, I’ll start off with some simple funnel analysis
with users, go into some more advanced funnel analysis, and then I’ll talk
about getting right down and deep into individual text boxes and things.
This is a little about the funnel. We start off thinking about a funnel in
terms of, well, the user goes here, then goes here, and then goes here. The
best one to think about is a sign-up form. You have a brand new user who
comes to your website and he’s really excited about your web app. He’s
like, “Oh, my God, I totally want this.” He goes to the thing, starts to
sign in, clicks next, types some more stuff in, types next, clicks some
more stuff, and says “Ah, this is too much for me. I’m going home. I’m
going back to Facebook.” At that point you’ve lost the user, and that’s not
what you want.
If you’re going to take an analysis of that, you’re going to see where
they’re going to fall off. That’s kind of important, especially if you’re a
startup. Every single user at that point in a startup’s life counts. You
want to engage them. You want to get them in there fast and you want them
hooked in to stay in there. Once they start investing time into your site,
they’re going to be a long-term customer.
This is just an example I’ve kind of thrown together. Page A is the
homepage, page B is the video page, and then C is actually the video. The
first question is where are the people coming from? Are they coming from a
Google ad? Coming directly from you typing something in? Twitters? Blogs?
Where are they coming from?
Once they come in here, what are they doing? What’s going on? We’ve got a
hundred users on page A, and then a couple of them go away. 62 on page B,
and then a couple go away. Then a bunch of them go away, and 21 people look
at the video.
That’s pretty interesting data, because what were looking for is, we’re
looking for really big drop-offs, here. We’ve got a big drop-off from 62 to
21. That’s a big problem. Either that video is not really awesome or not
enticing. Maybe it’s the wrong video. Maybe that’s not the video they are
looking for. Maybe there are not enough kittens in it. Who knows? That’s
another thing you’ve got to think about. Where are they dropping off?
So then go back. Where are they coming from? This is now what we talk
about, what SEO people talk about, the inbound metrics. This is something
that will just give you a basis around what inbound metrics are. We have
organic, which are algorithmically chosen results from Google. You type
something in, you get a bunch of stuff in the middle, and then around it
you get a bunch of pay to play stuff. This is PPC ads. People pay for those
things. If you really want to piss people off, go click on them. You’re
costing money, no joke, especially car ads, car insurance, and payday
loans. That’s bad. They’re like $20 a click, you know that?
Audience Question: What?
Chris: Yeah, they’re pretty bad. They get pretty bad.
Audience Question: Which ones? If an ad’s clicked more, they pay more?
Chris: Yeah, different ads, especially higher. It’s like pay per play.
Anyway, what we do, at least our company, we actually separate between
brand traffic and non-branded traffic. This is just a little bit of
background. Let’s say the actually client is TicketLeap. If you type in
Tickety by name, you should come up as number one. If you don’t come up as
number one for your brand name, that’s a pretty big problem, just FYI. It
means I don’t know what you’re doing wrong.
Then we look at non-brand traffic, “free ticking software.” The big thing
about this is, when you think about just a sales funnel, the non-branded
stuff, people are looking for a solution versus by the time they get to
branded traffic like Tickety, they’ve chosen you as their choice.
So it’s important that you kind of rank for keywords that are in your
industry and keep them coming to your site.
Some general terms that I might throw around throughout the presentation.
Visits. This is the precise definition according to Google. A visit is a
user time out of 30 minutes or midnight local time, as defined by the time
zone setting in Google Analytics.
Your exit rate is, if the user left the site, they may have visited more
than one page. That’s okay.
A bounce is actually what I consider a subset of exit. They only visited
one page and they left. So they went to the homepage and they ran away.
It’s most likely that the whole site itself was not relevant. It’s like a
spam site or something. Then the bounce rate is just a division of the two.
General terms for interpretation. Visits obviously are good. Lots of
visibility, people look at your stuff, awesome.
Exits are normal. People leave websites. They go to other things. They eat.
They sleep. They do stuff.
Bounce rates, something that I know a lot of people do is they go, “Oh, my
God, my bounce rate is like 60%. It’s ridiculous.” Chill out. It’s cool. It
doesn’t necessarily mean it’s bad. It has to do with the context of the
page. If the bounce rate is on, let’s say, a blog post, that’s okay. You
read my blog post, you left, cool.
Audience Question: If they click anything on a page, does it still count as
Chris: No, a bounce is only if they hit that one page and leave.
Audience Question: Okay.
Chris: If you’re considering the context of the page, let’s say it’s a
sales page, and they have to go through the next step where somebody gets
more information, let’s say it’s a white paper, and they bounce from that
point, that’s a bad thing.
All I’m saying is that a high bounce rate is not necessarily bad. Just
think about the page itself.
This is what it looks like in Google Analytics minus the big, black boxes.
You’ve got navigation on the left-hand side. You’ve got all kinds of stuff.
You get a big, fat graph in the middle and then down at the bottom,
basically, is the spreadsheet version of the graph. Okay?
Some things to note: visits and pages and bounce rate are over there. Then,
in this case, what I have listed out is just where the traffic came from.
We have organic Google traffic. We have Facebook traffic as a referral,
things of that sort. Okay?
Mixpanel does not have inbound data. I don’t know why. I was actually
looking for it and I typed it into their help. They don’t have it. So
things that you can’t get in Mixpanel are things like, what did somebody
type into Google and click on to your find your website? Did they type in
“free ticketing software?” You don’t know that. Mixpanel will not do that.
Google Analytics will do that for free for you. You get that when you put
in the code. They populate all that stuff for you.
The very big background, if you ever hover your mouse over the blue link,
there’s all this shit down at the bottom, this giant query string. That’s
what it is.
That’s cool. Nice graphs, pretty stuff. How do I get that? Very, very
simple. Sign up for Google Analytics, add it to your website, they spit out
this code, and you cut and paste this right before the end of your head
tag. That’s it. You don’t type any code. You just copy and paste it.
You can sound impressive because now you can say, “Oh, yeah, visits, bounce
rate, look at all this stuff we can get. Look at all these graphs we can
get.” That’s great.
Because this is a Ruby group, this is kind of how I’ve done it. There are
probably much nicer ways of doing it, but because I’m really fast and
really lazy, I just did it this way. In my Rails app I have the application
HTML-ERB file and right there I just say render a partial, render my Google
Analytics partial, and the partial is this. Cut and paste, boom, I’m done.
Now it’s on top of every page. It loads every time.
I’m sure you can do some more interesting, more intricate things with that
but that’s my version.
We have a funnel set up. We have all this data. It’s collecting all this
stuff. It’s doing it all automatically for you. Let’s talk about the funnel
itself, because now were going to talk about the users themselves.
Where are they falling off and that are they doing? The funnel
visualization, there are a couple of ways you can get to that in Google
Analytics. If you just go to Admin, Goals, and then Create Goal, you get
something that looks like this page, which is a bunch of tabs and stuff
like that. Name your event. The goal type, you can pick either a URL, the
set up the flow of each page that you get.
In this case, we picked a URL destination. The destination was the Add a
New Event page. This is actually Tickety’s goal-setting. It was a test one,
so this is not real anymore, FYI.
Basically, we’re trying to get everyone from the homepage into the sign-up
page, past the sign-up page into creating an event, and actually finishing
that event. All the way through, top to bottom, and then either publishing
it or saving it as a draft.
As soon as you hit that events page, boom, that’s a goal. Then you’ll see
step one, step two, step three, some names, and things of that sort. You
can use either regex or just straight strings for the URL, so if you have a
controller and there’s maybe a big, fat slug in the middle or something, a
bunch of random numbers and random characters, it’s okay “.*” is cool. Just
leave it at that. That’s what it looks like.
Audience Question: Quick question.
Audience Question: Can any of the steps be events, you know, mix events and
Chris: No, one or the other. There are some caveats with that and we can
talk about that afterwards, but there are a couple of small things,
especially about events and the funnel visualization.
Audience Question: You could just make up an event for page views?
Chris: Yeah. Real quick, what you can do is, as long as the URL shows up,
you can do an HTML5 pushState or something.
You can also fake it. What we’ve done in the back-end is we just send
just actually tell it what I want it to say, regardless of what the actual
page is doing. So there are ways around that.
Again, this is Mixpanel. On the right-hand side, they have the steps as
events. They can’t do URLs. They can’t do any of that stuff, which, in some
cases, is great and, in some cases, may not be. You have to decide what’s
better for you.
Just FYI, I bet if you did a full HTML5 backbone sort of app, Mixpanel
might work out better for you, because it kind of fits that whole mantra,
but if you have some older site that you stuck to, you might want to try
If you’re looking at funnel visualization, this is basically what it comes
out as. You kind of get this kind of green bar thing. You get a bunch of
users at the top. They go down, they go down, they go down, what pages they
entered, and then what pages they exited on. You can see that.
The new Google Analytics, they have a bunch of new visualizations. This
one’s very, very 1998. This one is very 2000-ish, modern art-ish. It’s kind
of cool. You can click on stuff and it expands and moves around and does
all sorts of funny things and lights up and blows up and explodes and makes
noises. No, I’m just joking.
are at the very bottom and then you get little bars across it. It looks
pretty easy to set up, so that’s kind of cool.
There is another way to look at how your users are dropping off. This is
the one that I actually use, because it’s great to know that they’ve
dropped off between two points of dates, but I want to see the aggregate
I made a bunch of changes to the site. We took a form from two steps to one
step. Are they leaving more or less or the same? What happened? I want to
see this over time. To do that, just go to the exit pages, because I’m
going to look at the people who exited, go over to vs. page views, select
that from the list at the top, and then filter out by the URL that you
What you get is a graph at the top like this. Page views is the dark blue
line and the exit percentage rate is the lighter blue line. This is
actually what happened to us. Right there in that green circle, we took it
from a two-step form to a one-step form. It used to be enter your name,
enter a password, enter a user name, enter the e-mail address and a
password, next, enter a domain name, next, and then you get the event
We actually smooshed it into one. Now it’s just name, e-mail address,
password, and slug. So you get all in, hit next, and it goes right to the
next page. That literally dropped the exit rate by 62%, just that one
change. So now were talking about, in the context of maybe 20, 40 users,
additional with one change. Keep in mind, too, now you have one less
controller to deal with.
Did anybody notice that I wrote no code? This is all the copy and paste
stuff. I didn’t touch anything yet. Think about that.
Audience Question: Are you able to use code?
Chris: Yeah. That’s where we’re going right now.
Advanced, this is the advanced version, okay? We’re going to continue on,
and this time we’re going to use segmentation. Segmentation is built in,
but you have to define it for Google. You have to tell it what you want.
For example, who’s being a quitter? I’ve got a bunch of people who are
leaving the site. That’s not good. I want to know who they are. Are they
first-time people? Are they returning visitors? Are they high-rollers I
really, really want on my site because they have a lot of money? I don’t
What we’re going to do, what I would do, is take our view–and this is a
elements. I’m sorry, five, technically. Slot number, you have five. The
string? Anything you want. Usually it’s a category or user type, and then a
value. That’s another string. I set it to new user and then enum
which is a scope, one, two, three.
The two scope means that it is a session view. In other words, if you go to
the site and you’re there for half an hour or whatever using my site, I’ll
tag you as a new user for that session until you either stop playing with
my site for half an hour or midnight happens, one or the other. That’s what
Let’s just say that for some reason, there’s some page in my thing that
says. “Hey, you have a lot of money?” Well, I’m going to basically say,
“Okay, now you’re my demographic. Now you’re my high-roller. Mr. Moneybags,
I’m going to change you over to this.” That’s the next thing.
The last value that you set wins for that session. Does that make sense?
The last value you set wins. It’s just a variable. It’s just an array. If
you guys know how use arrays, this is very easy. I hope you know how to use
In Google Analytics, this is where it shows up. If you go to Advanced
Segments and you click here, there’s this nice little GUI interface. You
can click down, type in–it’s like a drop-down box–type in whatever you
want, go through your custom variables and say, “Hey, I want you to give me
all the users for whatever view I’m in, and I only want to see just
Moneybags. I just want to see people who have a lot of money. What do I
Well, what we can do with that is, I can then say, “Okay, where did
Moneybags go away?” I want to know that, because I want to know, if he fell
off of that page, I want to make sure I optimize that page to make sure he
does not leave. He stays engaged. He’s there. He runs in. He gives me his
credit card. I take all his money. That’s what I want.
Go to Exit Pages. Tick in that URL, which is whatever it happens to be.
Click the advanced segment that you created and find out where he went.
Hey, look. He stopped leaving. Oh, no he didn’t. He came back. He kept
What you can see is, you can see over time, if you made any changes, now
you can see how it affects a specific type of user. In this case, people
with a lot of money.
By the way, there’s some cool stuff back here, down here. This is, again,
you get a lot of this for free. I’ve typed in one line of code so far. Copy
and paste to launch it and I typed one line of code. This is what you get
In the secondary dimension, I can take all those pages. I can take the
user, whatever I want, and I can look at the source. Where do you come
from? Facebook? AirBnb I don’t know. What medium did he use? Did
he click on one of my ads to start from? Did he come from there? If he went
through Google, what did he type in? “Expensive ticketing software?” I
don’t know. It’s kind of ridiculous.
What landing page? Did he come in on the home page? Did he land over here
and, if you think about that, you say, “Well, if he came over here on page
C and he went through the funnel, but if he landed on page A, he only went
halfway through the funnel. Something about those pages is doing well for
people with a lot of money, and this isn’t doing anything for these kinds
So those are the sorts of interesting things you can think about,
especially in terms of the user, where maybe you’re trying to attract a
type of user. You have web app like coupon software. Maybe you might have
one page that’s pink and one page that’s blue, and the page that’s pink
seems to do a lot better than the page that’s blue. Why is that? Maybe you
have a lot of Mommy bloggers going to your site and just going crazy. Maybe
that’s true. Who knows?
Other things you get in the second box. Cities, browsers, and screen
resolutions? Yeah. Cities, you can get straight down to the city, all the
way down to the city. You can look by the browser. You can see if they’re
Chrome, Firefox, Internet Explorer, AOL, if people still have that. Screen
resolution, it will let you see that. It’s actually funny, if you look at
that over several years of data, you’ll see screen resolutions start to
rise. The big one I’m mostly seeing is 1280×1024 or something like that,
the widescreen version of 1280. It’s kind of interesting.
So here’s a bunch of cities. What I did is, I sorted in ascending order of
percent of exits. I said, “Well, hey, check this out. People who came from
Rockland didn’t leave. People who came from Baltimore, they ran away. I
don’t know what’s wrong with Baltimore.”
Audience Question: Back to screen resolution. Do they track screen
resolution or window size?
Chris: Screen resolution, not window size. Good question.
That’s what I did.
This is kind of interesting. One thing you can do with that is you can say,
“Well, hey, we’re getting a whole load of new users from Seattle for some
reason. What’s going on there?” Maybe you got hooked up at a meet-up there.
Somebody talked about your software and all of a sudden you’ve got a bunch
of jump-in users from Seattle. Okay, that’s kind of cool to know. Maybe if
it’s on the Internet somewhere–and you can probably Google that–you can
reach out the guy and be like, “Hey, did you debut my software? I’d love to
give you guys a bunch of free trials to get you hooked in. Cool?”
Okay, now that we know where people come from and what they’re going
through and what they’re doing, let’s talk about how engaged they are. Are
they actually using your site or are they just clocking around like, “Eh,
this site sucks. I’m out of here.”
on forms itself. To answer the question, basically, why are they dropping
away? What’s going on?
This is what the code might look like. This is in the form, so what I would
have is something like form four, and then a text field, and then a class.
I think Brandon had a much more . . .
Audience Question: Or behavior.
Chris: Or behavior. Actually, I’ve seen that implementation. It’s actually
is really, really good because what you can do is, you can basically take
through the asset pipeline in Rails. I’m just doing it this way so I can
just kind of show you how it works. You guys can make it far more
efficient. This is a PowerPoint. It’s not VIM or something. In my form I would
I just want to stop for a second and talk about text boxes, because I had
to think about this for a while when I was doing it. A text box you can
click in. A text box you can tab into. A text box you might type something
in, you hit backspace, you didn’t like it. So there are a couple ways you
can say, “I detected interaction with this text box.”
So if you click, if you set onClick, well, yeah, I clicked on it and that’s
okay, but people tab into this text box so that doesn’t count. Well, maybe
if I type something in. That’s okay. You can also fire an event every time
somebody types in, but keep in mind there’s a limit. Google has a limit on
the number of events you can fire before they just stop tracking it. So you
don’t want to do that either. You just want to track it once and dump it.
Okay, well, maybe if they hit the submit button, I check the text box to
see if there’s something in it and then fire the event. What if they never
hit the submit button? What if they filled in half the form and then just
went away? I want to know that. I want to know they only filled in half and
I want to know which half they filled. Maybe I’ve got to cut it off at that
So, just kind of the small thought process that went through my head when I
did this. Onblur is probably one option. That’s the option I chose. You
guys can pick other things much more clever than me.
So where does all this stuff end up in Google Analytics? Well, it ends up
on the events flow. So if you go to Content, Events, Events Flow, in this
case I’m actually adding an advanced segment. I said, “Oh I want my new
users please. I want you to go to this page, and I’m going to click on that
specific page for sign-up. Then I’m going to click on secondary event and
pick my label that I want. Then I’m going to sort by unique events in
descending order and then click on the back button.
I do a lot of this because it gives me a very, very interesting set of
data. It gives me this. What this is, it shows you a graph of the number
of, over time, for one month, what people did on this specific form.
Were they interactive with e-mail addresses, password? I tracked validation
errors, who signed up for Tickety, who clicked on the slug, who did all
this other stuff, and it’s in descending order. Here’s why that’s
interesting. This is the form itself, and this is what I’m looking for,
specifically. I want to see if the actual events happen in the same order
as the form actually got filled out. So here’s the e-mail box, there’s the
password, there’s the URL, and there’s the create account button. Makes
sense. You’re filling it in.
Did you notice how, on the right-hand side, the numbers got smaller and
smaller? People are typing in, they’re getting through it and then they’re
like, “Eh, I’m not going to bother.”
This is interesting. If you have a form that’s 50 fields long, do you think
people are actually going to go through that? No. This is actually the data
that proved it to me. I knew it in my head, I’ve read about it, but this
actually proved it for once, which is cool.
But wait, why is the next one a validation error? What the hell is up with
that? That’s kind of weird. Is the password too strict? It’s eight
characters. That’s a pretty long password in my opinion. When I go to sites
that I don’t care about I only have a five character password. It’s like
one, two, three, four, five. I really don’t care. If you hack that thing,
it’s cool. I don’t care. That’s eight characters. Well, I’m going to
investigate that. I’m going to look at the data and find out if that’s
real. Is it real? How many times did people actually type in a password?
You notice how this is actually a big, fat number? It’s 22% over all of the
other ones, so maybe it is the password. That’s kind of interesting. If you
look at the two numbers against each other, the click on the sign-up and
then the number of times they click on password, it’s 1.6 times more.
Basically, what I’m saying here is, people type it in. They type in a six-
character password. They hit accept. They hit okay, and then the validation
error comes in, like, “Oh, hmm, 1.6 of those times they will do it again.”
In other words, instead of people doing it twice, only 1.6 times will they
do it. Basically, you’re losing a small section of people just because of
the validation error. They’re not doing it twice. They’re only doing in 1.6
times. Does that make sense?
So, what was the recommendation? I said, “Take that password and make it
You could actually go a little further with that. I could track an event
that says, “Okay, count the number of characters that are in that text
box.” I really wanted to, but I already had two points of data that pointed
me to the answer.
tracks this text box with six characters and test it out, maybe test it out
back and forth with 500 users, and were going to run this for a week?” No.
“Listen, you’ve got bugs to fix. You have shit to do. That’s not what I
want you doing. I’ve got two points of data that say otherwise. Just change
it to six and let it run and we’ll look at this number later.”
That’s the sort of thing that I would want to use with this data, to look
at it and say, “Where do I put my resources? Where do I put my time? Do I
have you spend all your time on that feature and that bug, or this feature
and that bug? What do I fix?” Look at the data and find out.
Kind of cool, they have something called “analyze event flows.” You can see
what the first event was, and the second event was, and the third event
was, and you get all these little lines and you click and see, “Okay, they
typed into this and this and this, and that’s pretty cool. Then after the
fourth event they got pissed off. You see that big, fat red line over
there? They got pissed off and left. That’s an exit. That’s not good.
Here a problem I see. This is the only thing I don’t like about Google
Analytics, by the way. My problem with it is it looks like spaghetti,
right? This is really hard for me to read. I call this the spaghetti
problem, where you’re looking at tons and tons of events and you’re like,
“Well, that one leads to this, but then there are 6% of users,” and your
head will explode looking at this.
It’s really actually possible because, keep in mind, if I have five tabs
open, I can technically fire events out of order. If you have a page A that
has a link to page B and then I go page A, page C, like, “How the hell did
you get to page C? There’s no link on page A for page C. That’s impossible.
How did you get there?” It’s a browser tab.
So you have to kind of just understand that there is at least a caveat at
looking at it this way.
I would say, if you want to use this, use it for a small-use case, where
there’s not a lot of stuff to do and not a lot of branches to go off of on
your page. So, in this case, they had links at the bottom of the footer,
there are links at the top of the page, and there are all these buttons
going around. I wouldn’t use it for that. I would use it from something
very small, very targeted, maybe a specific problem you’re having. That’s
what I would use it for.
So, unfortunately, I didn’t have time to really dig into this, because I
just found this last week, anomaly detection. I don’t know if you guys
know, there’s a thing called PostRank. Basically, it’s just an algorithm
ranking system for posts and stuff like that. They got snapped up by Google
and now they guy works for the Chrome team. He makes it faster and stuff.
Well, his blog is awesome, just FYI. It’s igvita.com. Go check this guy
out. He’s awesome.
Just two months ago, he posted this, “Web Performance Anomaly Detection in
Google Analytics.” Basically what it is, they use their algorithm to find
anomalies in the data and then they will e-mail you when things are
happening, which is kind of wild. I was like, “Shoot, I wonder if I can do
this for users.” Like, “Oh, shit, I got a link from TechCrunch. Damn! And I
didn’t know about this?” Like I’m not watching my thing, or my AWS just
fell over and I had no idea, which I probably should because I’m a shitty
devop. I don’t scale very well. Things fall over on me.
So this is kind of cool. There’s a Bitly link if you want to grab it. Take
a look at that blog post and try it out. If anybody plays with this, let me
know how it is, because I would love to dive into this. I just haven’t had
That’s really all I have. I would just say, in the end, that Google
Analytics is way, way, way more than just page views and stuff. There’s a
lot of stuff you can do with this, and if you know a little bit of
That’s all I got. If you have any questions, we can answer them now. If you
think of any later, follow me on Twitter. I tweet a lot about code and
things so just grab that and follow me and let me know what you think.
Audience Question: I do have a question. I noticed that the same text for
pushing the created event, I’m thinking, like, if it’s on a mobile device,
and a user picks something that was pushed to the event array, is it queued
or cached from local storage and, then, let’s say five minutes later, the
user reconnects, would that event be lost or guaranteed to be pushed to the
Chris: That’s a great question. I don’t know the answer to that exactly,
but I can tell you that what happens is, when you put that code, that
copy/paste code in there, it asynchronously downloads ga.js, and what that
does is it actually overrides push for arrays and, as soon as you put
anything into _gaq.push, anything you put in there, it immediately fires
out. It literally fires out immediately.
if it’s you’re phone, your phone is downloading YouTube videos and grabbing
music off iTunes and your Internet sucks and you have one bar, I can
probably guarantee you that, even if it fires, that shit won’t go out
anyway, because your phone is doing too much.
Audience Question: So, there is potential there, a possibility that the
event tracking might not be fired completely.
Chris: Correct. Yes, there is a possibility. There is a possibility.
Audience Question: I’m trying to find out if Google really tries to work
the best they can have some sort of queuing local cache.
Chris: This, to me, comes down to the question of accuracy versus
precision. What we’re going to say is, to me, the ultimate question is, the
numbers I see in Google, is that accurate? Can I trust those numbers? The
answer is maybe, okay?
Here’s the thing. If you think about accuracy versus precision, if you have
a bulls-eye, and every shot I make that I fire into that bull’s-eye is
fairly close to the center, that’s pretty darn accurate. Now, if I keep
firing at this one spot in the left-hand corner, but it’s like this close
together, all the shots are like this close together, that’s precise.
That’s what Google is trying to do what Google Analytics. They’re making it
precise. To me, that’s a little bit better because if it’s at least
precise, I can correct for accuracy. If it’s accurate but it’s kind of a
little inaccurate, I can’t really correct for that.
What I’m trying to say is, if you’re looking at this and saying, “Do I
trust those numbers? Do I trust the numbers I see in Google Analytics?”
what you should actually be doing is not trusting the numbers. You should
be looking at the trends of the data. The trends are far more important
than the accuracy of the data point itself, because, sure, if it’s always
6% off, it’s always 6% off. If that thing is going up and to the right,
that’s much more important to me as a developer and as a business person
than to say, “Well, the damn thing is 6% off so, fuck it, I’m not going to
trust this shit.”
Does that make sense?
Audience Question: Definitely, but I have one more question.
Audience Question: I want to check with you to see if this is a good idea.
record some events, say the user doing something or something unexpected
Chris: Like exceptions?
handle that, and you don’t want just events involving your user, could you
use Google Analytics to track those events and look at whether you could
put some sort of error code or description just to check what’s happening?
Chris: Absolutely. There are two ways you can do that. Number one, this is
an array. You can put anything in that array. It doesn’t matter. There’s a
technical limit of what length it is, but you can put anything in that
array including the exception.
If you do a try-catch, and at the bottom of the catch you say, “Oh, shit,
that thing blew up in my face, and I’m just going to push event,” that’s
one thing you can do.
By the way, Google Analytics has it built in that it will catch exceptions
not yours. Let’s say some crazy dude has some terrible badly-written jQuery
plugin and it blows up at the top of the page and nothing runs. As long as
you put Google Analytics as the very, very top thing, guess what? That will
get tracked for you under Google. It’s somewhere in the documentation but
it is something you can enable. It is not enabled by default.
You can try that.
Audience Question: Do you know if that tracks all errors by people? Because
a lot of times you get errors because people are doing something, right?
They load the page, they click okay while the page is loading, and now
you’ve got an error. So I’m wondering if you know if Google will actually
detect that or, because I just find that a lot of funny stuff when you try
to track errors, they’re annoying because we don’t know then what happened
Chris: I would have to say . . . there are two things I could say to that.
First off, what I try to do is, I always try to put the Google Analytics
code at the top of the page so that as soon as the page loads, it’s
asynchronously pulling something and, of course, ga.js was already cached
in the browser anyway, so it’s going to already fire. It’s going to be
loaded in memory. The rest of my page can do whatever it wants. If it wants
to blow up it’s fine. If it’s loading half the dom and they click next,
what it’s going to do is, that’s a page view according to Google, so now
it’s another page that page will catch whatever exceptions.
Long story short, yeah, it’s probably going to be annoying. I would
probably have to weigh how much of this stuff I want to track, because,
keep in mind, it’s going to throw everything on Google. You’ll have
thousands and thousands of tens of thousands of events in there, and it’s
going to be data overload so I generally only do whatever I must do and I
need to track.
I actually keep a log of what I’m tracking and then, when the marketing
people are like, “Yeah, we stopped that campaign,” I’m like, “Good. Die.
Kill that code. Get it off my page. I don’t want it running.”
Do you know what I mean? I don’t want extra lines of code when nobody cares
about the data, unless I say, “Are you going to need that later?”
“All right I’ll leave it there.”
Does that answer the question?
Audience Question: Yeah.
Chris: I’ll take yours and then I’ll come back to you.
Audience Question: We use both Mixpanel and Google Analytics and one of the
things that Mixpanel is a little more effective at is tracking back-end
events, because they have an API. That’s really the only reason we’ve kept
Chris: There’s something really cool I found just a couple of weeks ago.
It’s Analytics.js. It’s some sort of . . .
Audience Question: From KISS?
Chris: Is that from KISS?
Audience Question: I don’t know who wrote it, but you don’t have to change
anything. You just write one thing and it becomes a . . .
smorgasbord of all these analytics like Google Analytics, Mixpanel, I don’t
know, it has all sorts of stuff, and you just basically just have a big,
fat hash on the top of your page with all of your stuff. Then you turn it
on and it’s cool. It’s kind of neat.
Audience Question: Sorry, last one. I heard recently that Google Analytics
came out with a version for mobile apps. Can you comment on that? Have you
actually seen or played with it? Have you heard of anybody using it?
Chris: I know it exists. I have not played with it myself, so I can’t make
too many comments about it. I would assume that if it’s new from Google, if
it’s like anything that Google comes up with new, it’s awesome and it’s
probably very powerful, but there’s absolutely no fucking documentation on
it. Just wait about six months and the documentation will eventually show
That’s the only thing about Google. For some reason they’re really slow on
Audience Question: Question on the lines.
Audience Question: Thank you for the great presentation. My frustration
with using Google Analytics is that I’d rather write code than muck around
in their interface, and I can’t find a good tutorial on all this stuff. Is
this online somewhere?
Chris: It will be online and I’ve been requested multiple times. Actually,
this is like the third time I’ve given a presentation very similar to this.
This is the third version of the same presentation. This one is much longer
than the older ones. I’ve gotten a couple of requests for an eBook version
Audience Question: An eBook and then also pointers to, like, how did you
learn all of this, like your eight step thing with how to set up those
really interesting metrics? That’s a lot of steps, and I know I’ve never
found good documentation on setting all that crap up.
Chris: Playing with it a lot. Sitting down for a weekend and clicking
buttons. “What the fuck is this? Oh, that’s cool. Hey, what the hell does
this do? Oh, it just loads. That sucks.”
Also, I work at SEER Interactive, and the person who works next to me is
Rachael Gerson. She’s actually one of the top contributors to Google
Analytics’s help forums. She has everything in her head, so if I have a
question, I usually just ask her.
Most of it is just playing around with it because, keep in mind, they
change it a lot, too. That’s the other problem with documentation. It’s
sometimes a little behind.
Keep in touch with me. Like I said, if you have questions, shoot me on
Twitter or something. I’m always there to answer questions. I actually
answer questions a lot.
Audience Question: I had kind of a related question. I think it was, like,
over a year-and-change ago, someone was talking about trying to, instead of
integration testing your features, integration testing your business
proposal. To say that the goal of my project is to do X, Y, and Z,
something that you would basically test using Analytics, so getting back to
the code thing, do you know of anyone who’s trying to instrument tests like
this, to use code to build up testing areas like this or reports like this,
so you can almost unit test against them later?
Like, how cool would it be to basically have your CI script know how to
grab that report, so you can just throw it in and eventually the site is
going to go green and you’re like, “Okay, cool, we got it.”
Chris: Viget Labs, they have, there are a bunch of blog posts on Viget
Labs. They were using Selenium, it was either Selenium and PhantomJS or
just PhantomJS straight, and what they basically built is, they had random
wrappers and methods and stuff to, basically, automate, “Okay, the client
wants to track this.” We build a little test-suite for it. Click the
button, run the test, go nuts and it does it. It’s kind of cool.
Audience Question: They actually instrument like the UI? There’s no actual
API-level way to do it from your understanding?
Chris: No, well, what it is, a client will say, “Hey, I want these things
tracked.” So we’re going to hit that client’s website and make sure the
damn code is there. Then, when you click on the button, they might override
the method to make sure the dang thing fires and then just call the super
or whatever. I’m talking out of my, I’m talking wrongly, but you know what
I meant, right?
Audience Question: You talk pretty well.
Audience Question: The thing with [inaudible 53:53], we just heard someone
rewrapped the ga before he downloaded it and actually replaced it with
Chris: I heard you talking about that.
Audience Question: Yeah, [inaudible 54:01] theirs, so that every call that
goes through ga actually goes through us first, and then we can verify that
it’s actually going through the right way or sometimes we send it in two
Audience Question: But then you’re processing event streaming, you have to
process and serve the event stream yourself. I was thinking wouldn’t it be
cool if you could . . .
Audience Question: Yeah, you see the data coming through.
Audience Question: Yeah, I was thinking wouldn’t it be cool if you could
let Google do what Google does, just instrument it in some way so that you
could set up your test and then just forget about it and eventually get
Chris: If you want to do one-off testing, just FYI, if you want to do one-
off testing manually like me, because I’m crazy and I don’t do anything
automated, if you’re using Chrome, you can download a plugin called the
Google Analytics De-Bugger. What it does is it replaces ga.js with ga-
debug.js. It basically spits out everything into console, or the inspector
window, so if you open up the inspector window, literally just everything
just happens. Every fire, every variable, it’s just constantly streaming
everything that it’s doing, which I use to test. So if it just a one-off
thing, you can use that.
To your point, I thought the same thing and I looked it up and I thought,
“Viget Labs already did it, dang.”
Audience Question: Today we have Garb, which is the review library for it.
I think that’s one possible solution.
Chris: Garb is a Google Analytics library for pulling data out of the API
once the [inaudible 55:39].
Audience Question: I was thinking of basically writing a test that runs
that report but in an automated fashion.
Chris: Oh, okay. Sorry, I thought you meant like testing somebody’s
implementation, testing your implantation of Google Analytics on your site.
Audience Question: That’s helpful, too, but I think I’m more interested,
for example, in being able to write a test that says, “My exit rate dropped
by more than 50%.”
Chris: You can use Garb. You can also use mine. It’s called Gattica. I
don’t maintain it, so I’m just warning you of that. That’s really bad. I
don’t maintain it very well anymore.
Audience Question: So use Garb, is what you’re saying?
Chris: No, I actually have a totally different version of it now. It’s only
like its much, much, much, much smaller. It’s, like, 100 lines of Ruby. If
you guys really want it, I can give it to you. I don’t really care. It kind
of looks like . . .
Audience Question: Yeah, it looks like there’s a Ruby toolkit for it, so,
but I don’t know [inaudible 56:39]
Chris: Okay, I’m sorry. This actually grew. It’s 500 lines now. Actually,
what it is, it’s not even that interesting. The main meat of it is right
here it uses a OAuth2 gem.
Oh, you can’t see that, can you?
It uses the OAuth2 gem. Basically, it will grab the
OAuth2 gem, create a token for me, and then I have,
basically, fetch query, something like that, and then I say, “Okay, give me
all the organic, Google Analytics dot new, plus the account number, and
then dot organic landing page.
I think I need probably something like . . . it probably looks like this,
This is my little library and, basically, it’s just a bunch of wrappers
around this thing. This will get things like organic goal metrics, out by
medium, all it is, it just concatenates a bunch of stuff together, makes a
big-ass query string, sends it down to Google Analytics, returns it,
flattens out the hash, turns it into a flattened hash and then throws that in
That’s basically all this thing does, and if you really want, I can give
you guys this code. It’s not proprietary information. It’s not really that
interesting, and things of that sort. Well, maybe this is interesting, what
metrics you’re looking at.
So, that’s it. That’s what I do with Google Analytics.
Audience Question: Does Google Analytics show the real-time view of the
Chris: Yes. There is a new section for real time, so you can watch your
boxes go down as as its getting linked on TechCrunch, which literally happened
that time. I was like, “Hey!”
I was on Twitter and someone was like, “Hey, you got linked on TechCrunch.”
I’m like, “Oh, shit. This is bad.” One user, five users, 20 users, 115
users, zero. SSH … nope, it’s down. That’s awesome, did not scale.
Moderator: Any more questions? Last call. No? All right, thank you, Chris.
Chris: Thanks for having me.