Introduction
Recently popular applications for social. networks and browser games. Unfortunately, soc. Networks provide rather poor application statistics. Therefore, I had a choice: to collect statistics on my server, or use Google Analytics or something similar. In the end, I settled on Google Analytics. In this article I will tell:
- How to connect the application to Google Analytics?
- What opportunities does Google Analytics provide?
- How to track events?
- What and how to track?
I will touch on the main points. If the continuation is interesting, then I will write a new article that will already be targeted at those familiar with Google Analytics.
Application Connections to Google Analytics
To use
Google Analytics for an application, you need to create an account on the “Administrator” tab, and then add a new resource. After that, the code for your application will be generated on the “Tracking Code” tab. Code example:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', ' ID']); _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'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>
I note that when adding a resource, you need to specify not a link to the application, but a link where the application is located on your server. Example:
http://yoursite.com/forder_for_apps/my_love_app/
The code must be inserted on all pages that you will be tracking.
Google Analytics Features
Here, I will briefly go over the main features that are most likely useful to you.
')
Real time
Here you can see how many users are online. On what pages, from what countries.

Lecture hall
Here you can see who visited the application for a period of time.
You can view information about countries, browsers, providers about behavior and much more.
All this gives enough information about the audience and you no longer have to ask yourself questions about which browser to orient in the first place, and which one can be neglected.
Content
Here you can find information about the contents of the site, download speeds and events, which I will discuss in more detail in the next paragraph.
Goal conversions are a fairly voluminous topic, which is worth telling in detail. But in the framework of this article, I can not.
Sources of traffic - we are unlikely to be useful if the application IFrame. But there is a separate browser game, then you can find something useful.
Developments
Events are very simple to use, just insert the JavaScript code:
_gaq.push(['_trackEvent', category, action, opt_label, opt_value, opt_noninteraction]);
category - the category of the event. For example, step at registration.
action - event action. For example, reaching level 2.
opt_label is here, I usually put the user ID (optional).
opt_value and
opt_noninteraction are not needed for now.
Example of use:
_gaq.push(['_trackEvent', 'register', 'start_reg', 11111]);
Examples of using
Examples will be shown for VKontakte, but I think it will be possible to adapt them easily to other social services. network. The examples also use the jQuery library.
The user went to the registration form page:
_$(document).ready(function () { try { d = document.location.search.substr(1); var p = d.split("&"); var V = {}, curr; for (i = 0; i < p.length; i++) { curr = p[i].split('='); V[curr[0]] = curr[1]; } id = V['viewer_id'];
The user selected gender, name, character skills and sent a request to the server:
jQuery.post("../join/", { info_for_register }, function (data) { try { var json = JSON.parse(data); if (json.r == 1) {
Level up. Similarly. We will keep track of who reached 2, 5 and 10th.
if (mylevel == 1) { _gaq.push(['_trackEvent', 'register', 'level2', id]); } else if (mylevel == 4) { _gaq.push(['_trackEvent', 'register', 'level5', id]); } else if (mylevel == 9) { _gaq.push(['_trackEvent', 'register', 'level10', id]); }
Similar request, but we check what level at the user.
Now something more interesting.
Many applications feature: boast some achievement or purchase on the wall.
Previously, I used hash tags and watched that in the search:
vk.com/feed?q=%23swgames§ion=searchThe method was convenient, but it didn’t work very well. Then another covered up. Now the messages that the user posted through the application are not in the search. The search has become cleaner, but I lost my handy tool. I had to track with Google Analyitics.
VK.api("wall.post", { message: " " }, function (data) { if (data.response !== undefined) {
Everything is very simple.
Now I’ll tell and show you what it looks like inside in the Google Analytics panel.
Custom reports. Content. Developments. Overview.

Here we see how many went to the page with registration. How long has it been? How many reached 2nd, 5th and 10th level.
This is good information to think about.
If interested, then in the next article I can tell you more about Google Analitics for applications, and also write an article about how the registration was redone for the game and how it affected the number of successful registrations.
By the way, this is my first article on Habré.
I recommend reading:
Mining and processing of gaming trafficGoogle Analitics Guide (rus)Event Tracking. Official Documentation (eng)Flash Event Tracking